1. SIMPLE DYNAMIC QUERY
CREATE OR REPLACE PROCEDURE USP_TEST(P_OUT OUT PKG_NONPINS.CUR_REF) AS
Query VARCHAR2(1000);
BEGIN
Query := ' select trunc(sysdate) "sysDate" ,
trunc(current_date)
"curDate"
from
dual';
OPEN P_OUT FOR Query;
--OR
OPEN P_OUT FOR ' select trunc(sysdate) "sysDate" ,
trunc(current_date)
"curDate"
from
dual';
END;
2. PASS VARIABLE IN DYNAMIC QUERY
CREATE OR REPLACE PROCEDURE USP_TEST(P_OUT OUT PKG_NONPINS.CUR_REF) AS
Query VARCHAR2(1000);
Date VARCHAR2(1000);
C_Date VARCHAR2(1000);
BEGIN
Date := trunc(sysdate);
C_Date:= trunc(current_date);
Query := ' select ''' || Date || ''' "sysDate"
,
''' || C_Date || ''' "curDate"
from
dual';
OPEN P_OUT FOR Query;
--OR
OPEN P_OUT FOR ' select ''' || Date || ''' "sysDate"
,
''' || C_Date || ''' "curDate"
from
dual';
END;
No comments:
Post a Comment