Re: EXECUTE IMMEDIATE v_sql_stmt is not executing

  • From: Nik Tek <niktek2005@xxxxxxxxx>
  • To: Mark Van de Wiel <mark.van.de.wiel@xxxxxxxxx>
  • Date: Tue, 11 Aug 2015 10:22:44 -0700

Thank you Mark/Hans,

I was able to resolve the problem (it was the semi-colon at the end, which
was messing it up).

I used sys_refcursor to write the output to a file. It all works fine now.

Thank you for the help!
Nik



On Mon, Aug 10, 2015 at 4:28 PM, Mark Van de Wiel <
mark.van.de.wiel@xxxxxxxxx> wrote:

Nik,

Couple of things:

1) If you want to see the output of a SQL statement then this is not the
way to go.

This may work if you define an array (or something similar and use select
into in the dynamic SQL. Then loop through your array with dbms_output to
get PL/SQL to present you the output.

Alternatively use package dbms_sql.

You could also perform "create table as <your sql>" in the statement and
then following your PL/SQL code run some SQL to get output in sqlplus (or
some other tool you use).

2) Your dynamic SQL statement should not have a semi-colon at the end.

Hope this helps.

Mark.



On 8/10/2015 4:25 PM, Hans Forbrich wrote:

Which environment are you attempting to execute this in?

If SQL Plus, what is your server output setting?

/Hans

On 10/08/2015 4:58 PM, Nik Tek wrote:

Hi Andrew,

a) there is no output printing from the v_sql_stmt
b) DBMS_OUTPUT.PUT_LINE('v_sql_stmt: ------------------------ ' );
didn't print
c) If I copy/paste the output of DBMS_OUTPUT.PUT_LINE('v_sql_stmt: ' ||
v_sql_stmt);, I see the query working just fine.





--
Thank you
NikTeki

Other related posts: