plsqlEXECUTEIMMEDIATE动态执行sql

database

select*from BANK t;

DECLARE

v_money bank.money%TYPE;

BEGIN

--简单执行sql,注意sql字符串不要带分号结束

EXECUTE IMMEDIATE "SELECT money FROM bank WHERE id = 5";

--带参数,参数使用using传入,按顺序的传入

EXECUTE IMMEDIATE "SELECT money FROM bank WHERE id = :param1 or id =:param2"

USING "4","5";

--执行sql后,取值,using在赋值后面

EXECUTE IMMEDIATE "SELECT money FROM bank WHERE id = :param1"

INTO v_money

USING "2";

DBMS_OUTPUT.PUT_LINE( "Column Variable: "|| v_money );

END;

 

以上是 plsqlEXECUTEIMMEDIATE动态执行sql 的全部内容, 来源链接: utcz.com/z/534334.html

回到顶部