Sybase存儲過程點滴 使用存儲過程來執行DDL語句。
CREATE OR REPLACE PROCEDURE CNTL_DATA.alt_tbl(altsql IN varchar2) IS StoO_error INTEGER; StoO_errmsg VARCHAR2(255); BEGIN execute immediate altsql; EXCEPTION WHEN others THEN StoO_error := SQLCODE; StoO_errmsg := SQLERRM; RAISE_APPLICATION_ERROR(SQLCODE, SQLERRM,TRUE); END alt_tbl; 使用循環 FOR rciKorMaps IN (select regexp_substr(rciKorMapId,'[^,]+',1, level) as ids from dual connect by regexp_substr(rciKorMapId,'[^,]+',1, level) is not null) LOOP Query End loop 輸出行 dbms_output.put_line(SubStr('Error '||TO_CHAR(SQLCODE)||': '||SQLERRM , 1 , 255)); 事務例子 IS PRAGMA AUTONOMOUS_TRANSACTION; BEGIN INSERT INTO CNTL_DATA.cntl_log values (seq_cntl_log.nextval, in_job_id, proc_name|| msg, sysdate) ; COMMIT; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line('error:-->' || SQLCODE || ', ERR:-->' || SQLERRM ); ROLLBACK; END;