利用 Trigger 傳參數到 Procedure

dynamic SQL(include non dynamic)


    AFTER INSERT or UPDATE on TableName --新增或更新此table後觸發
    FOR EACH ROW
    CALL ProcedureName(:NEW.ColumnName1, :NEW.ColumnName2); --指定兩個column新增或更新後的值傳送至Procedure


AS

    varName1 number; --宣告變數
    varName2 varchar2(10);
    PRAGMA AUTONOMOUS_TRANSACTION;

BEGIN
    --將參數update至某table中
    EXECUTE IMMEDIATE 'UPDATE TableName SET ColumnName = ''' || paramter1 || ''' WHERE...';
    COMMIT;
END