Oracle/Access SQL question

Linflas

Lifer
Jan 30, 2001
15,395
78
91
I have a table in which one of the columns holds the names of other tables. Is there a way in SQL to use the table name from that column to select records from the table it names?

Table 1
UniqueID (indexed field)
<other columns>
ApplicationDataTableName

Table 2 (Name contained in ApplicationDataTableName in Table 1)
UniqueID (indexed field)
<other columns>

Any help will be much appreciated.
 

Haircut

Platinum Member
Apr 23, 2000
2,248
0
0
Firstly which are you using, Oracle or Access there is quite a difference.

In Oracle you can dynamically build up a string containing the SQL statement to select from Table 2 and then get the results using EXECUTE IMMEDIATE <SQL string>

I don't know enough about Access to know if you can do something similiar, but I suspect not.
 

Linflas

Lifer
Jan 30, 2001
15,395
78
91
I am doing it as a pass through query from Access to Oracle. I can also experiment with it using SQLPlus directly in Oracle if necessary.
 

Linflas

Lifer
Jan 30, 2001
15,395
78
91
Bump hopefully with more clarity.

Table1
UniqueID (this is the column I use for the lookup)
TableID <----Contains a table name
Field1
Field2


Table<Name of which is contained in TableID in Table1>
UniqueID
DataItem1
DataItem2

Kind of a generic SQL of what I need to do:

Select Field1,Field2,DataItem1,DataItem2 From Table1, Table<Name of which is contained in TableID in Table1>
Where Table1.Unique = Table<Name of which is contained in TableID in Table1>.UniqueID
 
Apr 16, 2003
179
0
0
No idea about Access and its support for Dynamic SQL but as Haircut said for Oracle Dynamic SQL is the way to do this.
It should be detailed in the PL/SQL reference manual or in Steve Feuerstein's PL/SQL book (my copy is at work so I can't say for certain). I find Feuerstein explains PL/SQL really well.
 

Linflas

Lifer
Jan 30, 2001
15,395
78
91
Thanks I think I saw that book over at Borders the other day. Sounds like it might be a good one to pick up. As for Access it is just a front end to get to the Oracle tables. I can do passthrough queries which are passed by ODBC to the Oracle tables so I use standard Oracle SQL syntax. I am not sure how it will deal with PL/SQL but it is worth a try. I have access to Oracle SQL Plus but the normal user I am working with does not which is why I am doing all this through the Access frontend.
 

Haircut

Platinum Member
Apr 23, 2000
2,248
0
0
If you are doing it through ODBC to Oracle, then your best bet might be to create a stored procedure in the Oracle DB and call this through ODBC.

You would need to know some PL/SQL to do this though, if you do go down this route then I thoroughly recommend the book by Steven Feuerstein that CaffeineAndStuff mentioned if you need a reference.
 

ecrespol

Senior member
Jun 28, 2000
572
0
0
Interesting idea.

Sorry to highjack your thread, but I have two simple questions on oracle/sql+.

1. Is there anyway via a simple sql statment add somthing like a conditional drop when a table does or does not exist (or based on a field in a table). Something that would work in SQL+?

2. In SQL+ is there anyway to increase the amount of text that can be pasted in at one time.

Thanks
 

bbrontosaurus

Senior member
Oct 25, 2002
469
0
0
Originally posted by: ecrespol
Interesting idea.

Sorry to highjack your thread, but I have two simple questions on oracle/sql+.

1. Is there anyway via a simple sql statment add somthing like a conditional drop when a table does or does not exist (or based on a field in a table). Something that would work in SQL+?

2. In SQL+ is there anyway to increase the amount of text that can be pasted in at one time.

Thanks

1) DROP TABLE <table name> will drop a table for you (provided that you have the correct privillages/or you are the table owner). If you have a table that does not exist, you will get the error ORA-00942: table or view does not exist. If it does exist, the table specified will be dropped. Is that what you are trying to accomplish with your conditional statement?
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |