Databases
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)