Home » RDBMS Server » Server Administration » From statement
From statement [message #371558] Tue, 07 November 2000 14:01 Go to next message
denise
Messages: 64
Registered: November 2000
Member
In my PL/SQL there is a table in a from statement that I need to use that will change each quarter. The beginning of the table name is always the same but the end changes by quarter. For example in quarter one it will be gcs_fytd_2001Q1 and for quarter three it will be gcs_fytd_2001Q3. Is there a way to pass the quarter to the table in a from statement without using an '&' variable?
Re: From statement [message #371559 is a reply to message #371558] Tue, 07 November 2000 14:18 Go to previous messageGo to next message
Christian Boulet
Messages: 9
Registered: April 2000
Junior Member
Hello, Of course you could use Dynamic SQL inside your PL/SQL to concatenate the deduced table_name with the rest of the select statement...

text:='SELECT AAA FROM '||tbl_part1||'_'||tbl_part2||' where bbb = 123';

in 8i you can use Native Dynamic SQL
OPEN CUR_AAA for text;
loop
fetch......

in 8.0.5 you'll need to use the old DBMS_SQL package...

Good luck!
Re: From statement [message #371564 is a reply to message #371558] Wed, 08 November 2000 05:02 Go to previous message
John R
Messages: 156
Registered: March 2000
Senior Member
You could create a view on the table, and simply recreate the view each quarter keeping the name of the view the same
Previous Topic: Re: how to update a table automatically
Next Topic: Re: executing a select statment in a package
Goto Forum:
  


Current Time: Fri May 03 15:44:12 CDT 2024