Is COMMIT required after every EXECUTE IMMEDIATE?

前端 未结 2 1615
死守一世寂寞
死守一世寂寞 2021-02-14 09:48

I have multiple EXECUTE IMMEDIATE commands within one oracle procedure.

EXECUTE IMMEDIATE \'DELETE  FROM tbl1\'; 
EXECUTE IMMEDIATE \'INSERT INTO tbl1...\'; 
COM         


        
2条回答
  •  无人及你
    2021-02-14 10:18

    The only times that you're really forced to commit, other thasn at the end of a business transaction, are:

    1. When executing DDL: the DDL execution is wrapped in a pair of implicit commits.
    2. After direct path insert: the table cannot be read until the insert is committed.

    As horsey comments, the correct point to commit at is when the business transaction is complete. Otherwise, you need to be writing yourself some code to detect and fix partially completed and commited transactions that have left the database is a logically inconsistent state (eg. An INVOICE record exists without any INVOICE_DETAIL records).

提交回复
热议问题