top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Can one use dynamic SQL within PL/SQL? OR Can you use a DDL in a procedure ? How ?

+2 votes
209 views
Can one use dynamic SQL within PL/SQL? OR Can you use a DDL in a procedure ? How ?
posted Feb 11, 2015 by Jayshree

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

CREATE PROCEDURE calc_stats (
w NUMBER,
x NUMBER,
y NUMBER,
z NUMBER )
IS
BEGIN
DBMS_OUTPUT.PUT_LINE(w + x + y + z);
END;
/
DECLARE
a NUMBER := 4;
b NUMBER := 7;
plsql_block VARCHAR2(100);
BEGIN
plsql_block := 'BEGIN calc_stats(:x, :x, :y, :x); END;';
EXECUTE IMMEDIATE plsql_block USING a, b; -- calc_stats(a, a, b, a)
END;

answer Feb 12, 2015 by Arun Gowda
...