select * from BANK t; DECLARE v_money bank.money%TYPE; BEGIN --簡單執行sql,註意sql字元串不要帶分號結束 EXECUTE IMMEDIATE 'SELECT money FROM bank WHERE id = 5'; --帶參數, ...
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;