SQL> exec execute immediate 'select count(*) cnt from dual where :1=dummy' using 'x';
PL/SQL procedure successfully completed.
SQL> select sql_id from v$sqlarea a where sql_text like 'select count(*) cnt from dual%';
SQL_ID
-------------
8y7sav2n21055
1 row selected.
SQL> ed tests/run_sql.sql
SQL> !cat tests/run_sql.sql
declare
vsql clob;
begin
select sql_fulltext into vsql from v$sqlarea a where a.sql_id='&1';
execute immediate vsql using &2;
end;
/
SQL> @tests/run_sql.sql 8y7sav2n21055 123
PL/SQL procedure successfully completed.
VARIABLE in VARCHAR2(10)
EXEC :in := 'X';
EXEC EXECUTE IMMEDIATE 'select * from dual where dummy=:1' USING :in;
字符串 如果你想得到一个结果,使用这个
VARIABLE in VARCHAR2(10)
VARIABLE out VARCHAR2(10)
EXEC :in := 'X';
EXEC EXECUTE IMMEDIATE 'select ''hello ''||dummy from dual where dummy=:1' INTO :out USING :in;
PRINT out
2条答案
按热度按时间xkftehaa1#
是的,这很烦人,但你可以像这样将查询 Package 到匿名PL/SQL块(脚本)中:
字符串
x1c 0d1x的数据
顺便说一下,SqlCl有另一个更简单的解决方法:使用
alias
:型
mzaanser2#
你试过这样做吗
字符串
如果你想得到一个结果,使用这个
型