Ado Query in Delphi 7 To Converts Joined Columns Into Rows Based on Primary Key - delphi-7

I'm using delphi 7 and ado query to connect to an access database with three tables
All the tables are related by Primary Key, i'm using the following query using ado query to get the three tables in one single row and it works fine :
select
table1.name,table1,amount,
table2.item1,table2.type1,table2.item2,table2.type2,
table3.item3,table3.type3,table3.item4,table3.type4,
from ((table1
inner join table2.id_data = table1.id_data)
inner join table3.id_data = table1.id_data)
order by table1.id_data
but what i want to achieve is to get each of item field (table2.item1, table2.item2, table3.item3, table3.item4) to be split or convert into rows (records), perhaps using cross tab or pivot, unpivot type of query, doing lot of search on the web and i'm still trying to figure out. is there any way to do this kind of query?

Related

Searching from all tables in oracle

I am developing a java app which can connect to oracle database and selecting column names from any tables, after selecting columns i have to query the data from those tables which the user select in my java app, now my question is how can i join all tables in the database so that query returns data successfully, i want to connect to any oracle schema to a specific, i will make the logic in java, but i am unable to find the query which can extract the data from all tables, i tried natural join among all tables but it has dependency of having same name of connecting columns. so i want to know any generic way which can work in all conditions.
As others have mentioned.. it seems that there are other tools out there that you probably should leverage prior to trying to roll your own complex solution.
With that said if you wish to roll your own solution you could look into using some of oracle's dictionary tables. Such as:
Select * from all_tables;
Select * from all_tab_cols;

How to rebuild data combination Power Query

In Power Query, I want to use a list of distinct values from one query (e.g. list of customers present on "Sales" table), to inject it on a SQL statement on another query (e.g. "Customer" dimensional table).
To pull the list of distinct values I have a function, getDistinct() that:
Retrieves one column from a query choice,
Only keep distinct values present on that column, and
Return these distinct values separated by commas so they can be injected within an SQL statement.
This function works fine on a standalone query. However, when I try to use it on my "Customer" query it throws an error (see code and error below):
let
Source = Oracle.Database("myServer", [Query="select * from db_customer where customer_id in (" & getDistinct(Sales,"CustomerID") & ")"])
in
Source
And the error:
Formula.Firewall: Query 'Customer' (step 'Source') references
other queries or steps, so it may not directly access a data source.
Please rebuild this data combination.
I've tried creating a different query that executes the function and then referencing it on my "Customer" query, but this doesn't seem to work. I know I can "Ignore Privacy Levels" (which by the way, I've checked and works), but since I don't know the implications of it, I'm afraid of leaked data.
I don't see why a function or any hand-written code is necessary for this requirement.
I would create a Query to get the Sales table and then Group by CustomerID. I would set that to: Load To / Only Create Connection.
Then the Customers Query would just be:
Source is Oracle Customers table
Merge to Sales Query on CustomerID, with Join Kind = Inner

create entity with specific list of columns using Entity Framework 5

I've got SQL tables with 100 columns and I've created model for that table.
I am using repositories to query table and I want specific columns (e.g only 10 columns) in my select statement to improve performance.
When I run SQL Server Profiler I can see it select all columns and I ant to avoid that.
Is there any way when DataContext try to query table then it uses entity with specific columns only?
If you are returning entities, they have to be fully-populated with data. If you need to get only certain pieces of data, use a projection.

SQL developer exports the query resultset one by one when array fetch size is 50

I have two SQL queries with joins on multiple table and where clause and i wanted to export the resultset (~80k rows) to an excel sheet.
In my first query (has join for 8 table and an left outer join) exports the data in multiple of 50 rows in the progress bar, whereas second query (has join for 3 tables and no outer join) exports the data one by one.
What would be the reasons behind it?
Note that, the preference is set for sql array fetch size as 50 in SQL developer.
Thanks,
Karthik

Linq to Entity Query .Expand

I got the following tables
TableA, TableB, TableC, TableD, TableE and they have foreign key relations like
FK_AB(one to many),FK_BC(one to one),FK_CD(One to many),FK_DE(one to one) and have the navigation properties based on these foreignkeys
Now I want to query TableA and get the records from TableA, TableD and TableE whoose Loadedby column equal to System. My query is like below
var query= from A in Context.TableA.Expand(TableB/TableC/TableD).Expand(TableB/TableC/TableD/TableE)
where A.Loadedby=="System"
select A;
The above query is working fine. I want the records from TableD and TableE whoose Loadedby value equal to System but the above query returning all the records from TableD and TableE which are related to TableA record satisfying A.Loadedby="System" this condition is not checked in the child tables.
Can anyone tell me how to filter the child tables also.
Currently OData only supports filters on the top-level. So in the above example it can only filter rows from the TableA. Inside expansions all the approriate rows will be included, always, there's no way to filter those right now.
You might be able to ask for the exanded entities separately with additional queries (with the right filter) and possibly use batch to group all the queries in one request. But that depends on the actual query you need to send.

Resources