Concatenate user paramater into table name for select query???
707224Jun 16 2009 — edited Jun 16 2009I 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!