user3620872
user3620872

Reputation: 41

how to retrive the value of variables outside dynamic pl-sql?

I perform the following query:

declare 
  i number;
begin
  execute immediate 'select count(1) from someTable' returning into i;
  dbms_output.put_line(i);
end;

and get this Error: returning clause must be used with insert, update and delete!

Upvotes: 1

Views: 171

Answers (1)

doberkofler
doberkofler

Reputation: 10361

Just a small syntax error (no RETURNING):

DECLARE
    i NUMBER;
BEGIN
    EXECUTE IMMEDIATE 'select count(1) from user_tables' INTO i;
    dbms_output.put_line(i);
END;

Upvotes: 1

Related Questions