Best practices: .NET: How to return PK against an oracle database?

前端 未结 3 1243
不知归路
不知归路 2020-12-30 14:42

With SQLServer, it seems to be generally accepted that adding a SELECT SCOPE_IDENTITY() to the end of your insert is the best way to return the PK of the newly-inserted reco

3条回答
  •  礼貌的吻别
    2020-12-30 14:58

    You can use the RETURNING clause to do this in Oracle stored procs.

    For example:

    TABLEA has NAME and EMP_ID. EMP_ID is populated internally when records are inserted.

    INSERT INTO TABLEA(NAME) VALUES ('BOB') RETURNING EMP_ID INTO o_EMP_ID;

    That's assuming that line is in a stored proc with an output parameter of o_EMP_ID.

    Hope that helps... if not, here's a more detailed example:

    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/returninginto_clause.htm

提交回复
热议问题