Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a stored procedure that makes an insert into a database. Something like

create proc InsAgent
@Name varchar(100),
@Age varchar(10),
@Message varchar(100) output

as 
insert into Agent values(@Name,@Age)
set @Message='Success'

 

My questions: 1. is it worth to use transactions with this kind of stored proc ?

 

2. If i want to exit a stored procedure i should type return

In some cases i saw "return" followed by a number: return 11 or return 10...

Is there any use for that number ?

Posted

Hi,

if this is the only insert/update/delete you do then using transactions is overkill.

You should use transactions if you do multiple changes in the database that have to be all successful. It's not the case here, at least not from what you've shown.

 

HTH

/Kejpa

  • *Experts*
Posted

For the RETURN, I usually use RETURN 0 to indicate SUCCESS, but RETURN by itself works fine. Normally, a non-zero value indicates an error. It's typical to use "RETURN @@ERROR" in SQL Server.

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...