Can one use dynamic SQL statements from PL/SQL?How can I use a variable for the columns/tables in the select statements?

Showing Answers 1 - 6 of 6 Answers

balaji

  • Jul 19th, 2006
 

yes,u can use dynamic sql statements in pl/sql.check the below code..

declare

        v_empno emp.empno%type  :=&empno;

       v_ename emp.ename%type;

       v_sal emp.sal%type;

begin

     select ename,sal  into v_ename,v_sal from emp where empno=v_empno;

     dbms_output.put_line('name  : '||v_ename||'    sal is  :'||v_sal);

end;

(u have to set the serveroutput environment option to on)

  Was this answer useful?  Yes

Rama Krishna,Yerra

  • Aug 2nd, 2006
 

This is also another method..

 Oracle Supports a built-in package

DBMS_SQL by this we can execure

We must use the following methods.

 PARSE()

BIND()

Thanks&REgds

Ramki,TCS,Hyd

  Was this answer useful?  Yes

jitendra

  • Aug 8th, 2007
 

You can use execute_imediate in PL/SQL.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions