Skip to content

2.3 Dynamic query in pl sql

thuantt0101 edited this page Jan 1, 2020 · 2 revisions

referencing

dynamic query

/* dynamic query in pl sql 1*/
declare 
nRET number;
begin
 EXECUTE IMMEDIATE 'select count(*) from R00DMDVCS '
    into nRET;   
    DBMS_OUTPUT.PUT_LINE(nRET);
end;


/* dynamic query in pl sql 2*/
declare 
nRET number;
vSQL_QUERY VARCHAR2(2000);
begin
 vSQL_QUERY := 'select count(*) from R00DMDVCS ';
 EXECUTE IMMEDIATE vSQL_QUERY
    into nRET;   
    DBMS_OUTPUT.PUT_LINE(nRET);
end;