Thanks, Schwertner...
I understand that. That's why I was asking for some sample code showing how I would use dynamic SQL to identify the tables.
Anyone?
Main Topics
Browse All TopicsHello Gurus,
I need to write a stored procedure that will extract data from a collection of dynamically created tables. For example, one table name could be 'TESTAPP_JL_1_2009' where the application name = TESTAPP and year = 2009. 'TESTAPP_JL_2_2009' = application = TESTAPP and year = 2009. There is no assuarance that these tables 'will' be created. These tables are created by an application - neither the code nor the schema is published. If someone could provide some direction or maybe some sample code, I would be very grateful!
Cheers!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I am not sure if you are looking for this. This is the part where i am using dynamic sql.
declare
var_ind_array ind_array;
begin
EXECUTE IMMEDIATE 'CREATE TABLE temp_tanf_indexes( COL VARCHAR(4000) )';
var_ind_array := ind_array();
FOR i in c_indexes LOOP
var_ind_array.Extend(1);
str := dbms_metadata.get_ddl('IND
EXECUTE IMMEDIATE 'insert into temp_tanf_indexes values(''' || str || ''')';
str:='DROP INDEX '||i.index_name;
EXECUTE IMMEDIATE str;
END LOOP;
end;
Business Accounts
Answer for Membership
by: schwertnerPosted on 2009-10-29 at 09:30:57ID: 25695415
When a table is created in the application the only way to use it is dynamic SQL
The reason is that if the table doesn't exist in advance the static SQL statement
against this table will cause an error (Table or view doesn't exist).