Skip to content

cx_Oracle hides NO_DATA_FOUND exception in an INSERT statement with RETURNING clause. #131

@felixxm

Description

@felixxm

cx_Oracle hides NO_DATA_FOUND exception in an INSERT statement with RETURNING clause. Please find below example that should raise NO_DATA_FOUND exception:

import cx_Oracle
connection = cx_Oracle.connect("user", "password", "TNS")
cursor = connection.cursor()
cursor.execute('''
    CREATE TABLE "ISSUE_TEST" (
        "ID" NUMBER(11) GENERATED BY DEFAULT ON NULL AS IDENTITY,
        "TEST_CHAR" VARCHAR2(10)
    )
''')
cursor.execute('''
    CREATE OR REPLACE TRIGGER "TRG_NO_DATA_FOUND"
    AFTER INSERT ON "ISSUE_TEST"
    FOR EACH ROW
    BEGIN
        RAISE NO_DATA_FOUND;
    END;
''')
v_id = None
cursor.execute('''
    INSERT INTO "ISSUE_TEST"("TEST_CHAR")
    VALUES('XYZ') RETURNING "ISSUE_TEST"."ID" INTO :v_id
''', {'v_id': v_id})

Other exceptions e.g. DUP_VAL_ON_INDEX, ZERO_DIVIDE, TOO_MANY_ROWS are raised properly.

  • cx_Oracle 5.3, 6.1
  • Python 3.5.3 (64-bit)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions