Return Data from a Hidden Table in Excel Web Query - excel-web-query

I am trying to return the values stored in 'Table 1' from HDIV, but Table 1 is hidden. The web query can see it under Web View, but won't pull it in. When I select and load Table 1, Table 2 is actually loaded. Is there a way to load the hidden table?

Related

How do I get rid of this Error:Column alias list has 1 entries but 't' has 4 columns available while creating a view on top of a view in AWS athena?

I have created a "dummy" table to access records stored in parquet in S3 & I have created a "dummy_flattened" view on top of "dummy" table using this query
CREATE OR REPLACE VIEW dummy_flattened AS
select
deviceid
, a.postid
, a.craterid
, a.posttype
, a.category
FROM dummy cross join UNNEST(postlist) as t(a)
example of a postlist row :
[{category=[{id=1, name=Dance}], craterid=1, postid=1, posttype=a},
{category=[{2, name=Dance}], craterid=2, postid=2, posttype=b}]
Now when I try to create a view on top of dummy_flattened view using the query
create or replace view test as select distinct deviceid from dummy_flattened limit 100
Athena is giving me the error :
Failed analyzing stored view 'logs.dummy_flattened': line
19:12: Column alias list has 1 entries but 't' has 4 columns available
but i can view the results with the same query mentioned above
select distinct deviceid from dummy_flattened limit 100
However when i don't include a.postid,a.craterid...while creating the dummy_flattened i can successfully create test view.
However I couldn't figure out how to create a view on top of flattened view that includes postid,craterid,postype..without running in to a error.
I have been trying multiple combinations for the past few hours with no luck.
A few of the combinations i tried while creating flattened view
1. select deviceid,t.* as (a) FROM dummy cross join UNNEST(postlist) as t
2. select deviceid,(t.a.*) as (c,d,e,f) FROM dummy cross join UNNEST(postlist) as t(a)
3. And the one i mentioned above at the beginning
I would like to know if i'm missing something or can we not create views on top of unnested records. I have been refferring to multiple documents and other similar questions in stack overflow but couldn't find anything. As a last resort i'm posting this
The version I'm using right now is Athena 3 and that's where the problem is. I'm not sure why but there's no error when I switched to Athena version 2. Might be a bug or something.
Docs mention that every column of the row in the array is expanded into separate a column:
UNNEST can be used in combination with an ARRAY of ROW structures for expanding each field of the ROW into a corresponding column
So you need to specify corresponding number of columns:
CREATE OR REPLACE VIEW dummy_flattened AS
select
deviceid
, postid
, craterid
, posttype
, category
FROM dummy,
UNNEST(postlist) as t(category, craterid, postid, posttype)

Need to populate table based on data in a csv file

I have a database table called "COL" that contains over 836,000 items purchased online by individuals. There is a distinct set of 330 items that I read in as a .csv file called "desc". Rather than deal with all 836,000 individual items, I would like to group them from 1 to 330. For this I've created a column in the table called "groups".
What I would like to do is read in an item from desc and update the table using an update query, but I'm a bit lost on how to set it up. I've provided some code, but I'm not sure how to run an update query in a for loop.
library(RODBC)
db <- "C:/Projects/stuff.accdb"
desc<-read.csv("C:/Projects/description.csv",header=TRUE)
col <- odbcConnectAccess2007(db)
for (i in 330)
{
sqlquery(col,paste("update COL set groups=1 where description='SLIP-ONS, LT, GREEN'"))
}
close(col)

Dynamically Changing Value in APEX Based on Select List Selection

I currently have a select list with the values: 1, 2, 3, 4 & 5. These correspond to a column in table "DVD" called "DVDID", and these are the only values in this column in the table.
In the table "DVDCOPY" records exist containing the all DVDIDs (1,2,3,4,5) with a different DVDCOPYID.
E.g. a record from the DVDCOPY table is:
DVDCOPYID DVDID DISCCONDID
1 1 1
My question is, how can I make it so that once a DVDID is selected from the select list, the DVDCOPYID changes dynamically based on this selection? E.g. once 1 is selected in the DVDID select list, the value for DVDCOPYID also changes to 1 automatically.
My form currently looks like this, if this helps:
APEX Form
You have to use dynamic actions and PL/SQL. Create a hidden form element which allows for element changes (no session protection enabled). Create a new dynamic action in your form guiding to the select list and using the onchange event. Your dynamic action contains two steps: first set the hidden form element to the value of your select list. Second: execute a PL/SQL statement (UPDATE DVDCOPYID SET ... = :NEW_HIDDEN_ELEMENT WHERE ID = ...).

Stored Procedure to display values from sql server

I am developing a windows application in vb.net. I have a requirement to retrieve values from a table based on certain criteria. My sql server table is as below.
tbl ACCOUNT_DETAIL
I have a textbox in my windows form for displaying the corresponding GL_Account. The user will pass the paidto value to the back end and the procedure must return the corresponding GL_Account. But there is one more criteria : while retrieving the GL_Account from the database, we need to check for wholefamily. If the WholeFamily is 1 then all the Accounts(should be fetched from another table) which starts with the GL_Account should be retrieved. Else only the GL_Account from "this" table needs to be sent. The table which contains the entire account information is below
tbl ACCOUNT_MASTER.
I have shown only a part of the data from the table here.
I have created a Cursor to fetch values from the Account_Detail table. But after fetching values i need to check for WholeFamily and based on the bit i need to pass values to the front end.
#PaidTo(int) is the SP Parameter that is passed from the frontend.
DECLARE #GLAccount VARCHAR(50)
DECLARE #AccountName VARCHAR(MAX)
DECLARE PV_CURSOR CURSOR
FOR
SELECT GL_Account,WholeFamily
FROM ACCOUNT_DETAIL
WHERE PaidTo=#PaidTO
OPEN PV_CURSOR
FETCH NEXT FROM PV_CURSOR
INTO #GLAccount,#AccountName
Now I am stuck as to how to proceed further. Sorry for my ignorance.
Please help me.
I would not use a cursor in such a scenario...
If I understand what you are suggesting correctly, incase Whole_family is 1 then you need to pull all info from the other table in the same result set. The below query can have multiple rows for every GL_Account based on your entries in the Account_master.
SELECT PAIDTO
, GL_ACCOUNT
, WHOLEFAMILY
, ACCOUNTNUMBER
, ENGLISHNAME
FROM ACCOUNT_DETAIL
LEFT JOIN ACCOUNT_MASTER
ON CASE
WHEN WHOLEFAMILY = 1
THEN ACCOUNT_DETAIL.GL_ACCOUNT
ELSE NULL
END = ACCOUNT_MASTER.ACCOUNTNUMBER

SQL.Working with views

I have a table 'Goods' with different information about goods (name, price, etc). I need to create a view at the same scheme as table 'Goods' has. But the view must be empty. And when user adds new good to the view it is saved in table 'Goods', but the view remains empty when user opens it next time. So main idea is not to show existing data to the user which has access to the view.
Assuming your on a database system that supports a concept like SQL Server's CHECK OPTION, and you're allowed to create a view that doesn't have that option set, you should be fine:
create table T (ID int not null)
go
create view V
as
select * from T where 1=0
go
select * from V
go
insert into V(ID) values (10)
go
select * from V
go
select * from T
The two selects from V return 0 rows. The select from T returns one row:
ID
----
10
CHECK OPTION:
Forces all data modification statements executed against the view to follow the criteria set within select_statement. When a row is modified through a view, the WITH CHECK OPTION makes sure the data remains visible through the view after the modification is committed.
And you want the opposite - you want to allow data modifications performed through the view to create rows which are invisible through the view.
Create table Goods1 with "insert trigger" on it which make insert into Goods and delete from Goods1
As far as I know this isn't possible. The whole point of a view is that it is a view to a table or grouping of tables, ie. it must show the data that matches the view.
http://www.w3schools.com/sql/sql_view.asp
What you could do is create another table called GoodsView and add a trigger to it to INSERT into Goods table and DELETE from GoodsView afterwards.
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=%2Fsqlp%2Frbafysqltrig.htm