|
-
Nov 6th, 2009, 07:32 AM
#1
Thread Starter
Addicted Member
get data from oracle and sql in one sql statement...
I will try and explain my problem as simply as I can 
I have an Oracle database (external app) that contains a number of tables that I need to get data from, however I also have an SQL database that contains a number of tables that my app is using.
e.g. Oracle Table name PD_112
Structure:
ID DISP_ID
1 5
2 8
3 5
e.g. SQL Table name DispTbl
DISP_ID DESC
5 Piping
6 Electrical
What I want to do is get all the data from the Oracle table to display in a list control however I want the values in the DISP_ID column of the Oracle table to be change to the corrosponding DESC values from the DispTbl e.g. 5 from the Oracle table would display Piping instead of 5.
I know how to do this if both the tables where in one database system e.g. Oracle or SQL, however I am not sure the best why to do this when the tables are in 2 different data sources.
Below is the code for doing this in the same datasource:
Code:
SELECT PD_112.ID, DispTbl.DESC FROM PD_112 INNER JOIN DispTbl ON PD_112.DISP_ID = DispTbl.ID
I am using VB.Net 2005, just for info
Any help would really be appreshiated
Thanks
Simon
-
Nov 6th, 2009, 07:37 AM
#2
Re: get data from oracle and sql in one sql statement...
Create a database link in Oracle to access SQL database, or implement comparable feature in SQL Server... its essentially a direct connection between the databases rather than relying on connection to application. The other table would then be a "remote table" that can be joined to local tables.
-
Nov 6th, 2009, 08:31 AM
#3
Re: get data from oracle and sql in one sql statement...
Also remember, the performance of your query will noticeably degrade.
The other alternative is to create a materialized view across the network in your Oracle DB. This view could be set to be refreshed overnight.
You might want to read this.
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Nov 6th, 2009, 09:24 AM
#4
Thread Starter
Addicted Member
Re: get data from oracle and sql in one sql statement...
I was thinking, is there anyway that I could run an SQL query on the Oracle database and hold this in a datatable and then run another SQL query on the datatable to achieve this?
-
Nov 6th, 2009, 09:29 AM
#5
Re: get data from oracle and sql in one sql statement...
 Originally Posted by lidds
I was thinking, is there anyway that I could run an SQL query on the Oracle database and hold this in a datatable and then run another SQL query on the datatable to achieve this?
A materialized view is akin to a table, except you cannot insert records in it.
Yes, you could also store the records from your SQL database to your Oracle Database. There are two ways I am familiar with.
1) This is the least complicated way. Export the SQL server table to a text file. Load this text file using SQLLoader utility in Oracle.
2) Establish a link between Oracle Data and SQL Server. Then run a CREATE TABLE AS SELECT * FROM {SQL Server Table}. This will create the table for you.
There's a third way I have heard of, but never used personally.
3) SSIS. This will let you push data from SQL server to Oracle.
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Nov 6th, 2009, 10:16 AM
#6
Re: get data from oracle and sql in one sql statement...
 Originally Posted by lidds
I was thinking, is there anyway that I could run an SQL query on the Oracle database and hold this in a datatable and then run another SQL query on the datatable to achieve this?
Depends on how many records are involved in the tables to be "joined by the application".
Yet another alternative, if the number of records from SQL Server table is relatively small and rarely changes would be to spawn a temporary table in Oracle and fill that up with records from SQL Server (passed through application connections)... subsequent queries can then be done at Oracle side.
But the best approach for OLTP would still be the database link; its relatively real time, doesn't incur additional storage and has to be maintained/synced regularly unlike materialized view, doesn't use up memory for long periods unlike temp table, and you'll need the link anyway if you want to go ahead with materialized view.
Last edited by leinad31; Nov 6th, 2009 at 10:19 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|