GeekInterview.com
Series: Subject: Topic:
Question: 107 of 190

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

Asked by: Interview Candidate | Asked on: Apr 29th, 2006
Showing Answers 1 - 4 of 4 Answers

try using execute immediate 'sql statement' ;

  
Login to rate this answer.
balaji

Answered On : 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)

  
Login to rate this answer.
Rama Krishna,Yerra

Answered On : 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

  
Login to rate this answer.
jitendra

Answered On : Aug 8th, 2007

You can use execute_imediate in PL/SQL.

  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.