Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Concatenate user paramater into table name for select query???

707224Jun 16 2009 — edited Jun 16 2009
I am attempting to write an end user report which will take a 2-digit user defined variable representing year and concatenate it to the end of a static table name.
The database design (not my design!) creates a new table each year. The only difference in table name from one year to the next is the last two digits representing the fiscal year.

I need to create a select statement which will allow me to take the generic portion of the table name and concatenate the two digit year on the end.

eg:
y_r = :par_yr

SELECT *
FROM table_name&y_r, table2_name&y_r

WHERE
table_name&y_r.primary_key = table2_name&y_r.foreign_key

I have tried several ways of accomplishing this all to no avail. I have spent hours searching the internet without luck either. I hope that someone can help with this.

Thanks in advance for your efforts!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 14 2009
Added on Jun 16 2009
6 comments
3,092 views