我执行一个动态SQL的查询语句结果在那里显示?
DECLARE AA VARCHAR2(100):= 'SELECT ‘aa’ FROM dual';
BEGIN
EXECUTE IMMEDIATE AA;
END;
假设就按上面这个语句,执行结果在哪里能看到。PL/SQL。SQL SERVER 直接在下面就将查询的结果拉出来了 PL/SQL需要设置还是就没有?
------最佳解决方案--------------------木有 可以将动态sql打印出来 然后运行
------其他解决方案-------------------- DECLARE AA VARCHAR2(100):= 'SELECT ''aa'' FROM dual';
BB VARCHAR2(10);
BEGIN
EXECUTE IMMEDIATE AA INTO BB;
DBMS_OUTPUT.put_line(BB);
END;
------其他解决方案--------------------set serveroutput on;--打开输出显示
DECLARE
AA VARCHAR2(100) := 'SELECT ''a'' FROM dual';
str varchar2(100);
BEGIN
EXECUTE IMMEDIATE AA into str; --查到的结果赋值给变量str
dbms_output.put_line(str);--打印str
END;
/
a
------其他解决方案--------------------CR%ROWCOUNT
------其他解决方案--------------------DECLARE
CURSOR CR (ID_IN PLS_INTEGER)IS
SELECT
A.ID AS ID,C.FID AS FID,C.FNAME AS FNAME
FROM AA A
JOIN CC C ON A.ID = C.ID
WHERE A.ID = ID_IN;
FF CR%ROWTYPE;
ZF VARCHAR2(1000);
BEGIN
OPEN CR(1001);
LOOP
FETCH CR INTO FF;
EXIT WHEN CR%NOTFOUND;
ZF := ZF
------其他解决方案--------------------FF.FID
------其他解决方案--------------------' AS FID'
------其他解决方案--------------------','
------其他解决方案--------------------''''