Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Is this proper way to insert an item in the databs

Author  Topic 

azamsharp
Posting Yak Master

201 Posts

Posted - 2005-12-29 : 17:26:03



CREATE PROCEDURE [sp_InsertHtmlContent]

@uploadLog_ID int,
@contFormatLU_ID int,
@contentSubPath nvarchar(200),
@contentFileName nvarchar(200),
@psFormatType_ID int,
@timesUsed int,
@contentBlob image,
@byteCount int,
@ctds datetime,
@m4Delete bit

AS

-- Id to be returned
DECLARE @returnValue int

BEGIN TRAN

INSERT INTO tblContentContentImport(tblUploadLog_ID, tblContFormatLU_ID, ContentSubPath,
ContentFileName, PSFormatType_ID, TimesUsed, ContentBlob, ByteCount, CTDS, M4Delete)

VALUES(@uploadLog_ID, @contFormatLU_ID, @contentSubPath, @contentFileName, @psFormatType_ID,
@timesUsed, @contentBlob, @byteCount, @ctds, @m4Delete)

-- If there is no error then commit the transcation
IF @@ERROR = 0
BEGIN
COMMIT TRAN
RETURN SCOPE_IDENTITY()
END
ELSE
BEGIN
ROLLBACK TRAN
RETURN -1
END
GO


Mohammad Azam
www.azamsharp.net

cshah1
Constraint Violating Yak Guru

347 Posts

Posted - 2005-12-29 : 17:36:44
Where are you setting this variable in your code...? Instead of RETURN SCOPE_IDENTITY() use output variable if you want to return the latest identity value.

-- Id to be returned
DECLARE @returnValue int
Go to Top of Page

azamsharp
Posting Yak Master

201 Posts

Posted - 2005-12-29 : 19:16:08
Ohh, yeah you are right. Apart from that do is the SPROC okay?

I forgot to delete the variable @returnValue since I don't need it.

Mohammad Azam
www.azamsharp.net
Go to Top of Page
   

- Advertisement -