I wanted to throw this out there for some ideas. I’m writing a program to generate insert/update statements, and I want the table that I insert/update to come from the results of a query. So something like (please forgive the syntax):
INSERT INTO (SELECT TBL_NAME FROM MYTABLES WHERE A=B) VALUES ('A', 'B', 'C');
I have to do this in Oracle, but I’m not too familiar with their declare statements or syntax. I’m guessing the best way to go about it is to declare a variable that is the result of the SELECT, but then can I use that variable as the table name for the INSERT?
I also want to keep the code in SQL.
Thanks for any ideas.
I think you may want to look into Dynamic SQL, you may find your answer (or at least a decent starting path) there.