Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

Can I use table name as variable in PRO*C/PLSQL?

SOLVED
Go to solution
MA Qiang
Regular Advisor

Can I use table name as variable in PRO*C/PLSQL?

EXEC SQL INSERT
INTO tbl_X VALUES (:test_rec);
EXEC SQL COMMIT WORK;

IF tbl_X is a variable, how to set and use it?

Best Regards.
1 REPLY
Alex Lavrov.
Honored Contributor
Solution

Re: Can I use table name as variable in PRO*C/PLSQL?

Hey,

It's called dynamic sql. In pl/sql it's easy, but it's a bit more complicated in proc*c.

Here's for Pro*C:
http://www.stanford.edu/dept/itss/docs/oracle/9i/appdev.920/a97269/pc_13dyn.htm

Here's for PL/SQL:
http://www.dulcian.com/magazine%20articles/Execute%20Immediate.htm
(immediate statement)

But remember, heavy use of dynamic sql, can cause performance problems. The switch between static and dynamic sql impacts oerformance.
I don't give a damn for a man that can only spell a word one way. (M. Twain)