Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Converting Scope_Identity from tsql to pl\sql

627047Mar 7 2008 — edited Mar 7 2008
Here is my MS proc:
CREATE Procedure [dbo].[sp_AddLabel]

(
@v_LabelName NVARCHAR(50) = Null,
@v_LabelDescription NVARCHAR(255)= Null,
@v_Label_Data IMAGE = NULL,
@v_ProfileID SMALLINT)
As
begin
INSERT INTO LABELS (LABEL_NAME, LABEL_DESCRIPTION, LABEL_DATA, PROFILEID)
VALUES (@v_LabelName,@v_LabelDescription,@v_Label_Data, @v_ProfileID)
SELECT scope_identity()
end


I am using sql developer and it converts the script to the following.


CREATE OR REPLACE PROCEDURE sp_AddLabel
(
v_v_LabelName IN NVARCHAR2 DEFAULT NULL ,
v_v_LabelDescription IN NVARCHAR2 DEFAULT NULL ,
v_v_Label_Data IN BLOB DEFAULT NULL ,
v_v_ProfileID IN NUMBER DEFAULT NULL ,
cv_1 IN OUT SYS_REFCURSOR
)
AS
BEGIN
INSERT INTO LABELS
( LABEL_NAME, LABEL_DESCRIPTION, LABEL_DATA, PROFILEID )
VALUES ( v_v_LabelName, v_v_LabelDescription, v_v_Label_Data, v_v_ProfileID );

OPEN cv_1 FOR
SELECT NULL/*TODO:scope_identity()*/
FROM DUAL ;

END;


It obviously doesn't have a scope_Identity type.

So my question is, what would I write to return the same result?

TIA
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 4 2008
Added on Mar 7 2008
2 comments
1,603 views