Re: Problem with Output param for stored procedure

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ben (Ben_at_discussions.microsoft.com)
Date: 12/10/04


Date: Fri, 10 Dec 2004 09:05:02 -0800

Adam has asked a couple times why you would provide an initial value to an
output parameter.

I have often used this method of parameterized stored procedures.

For example,
  I have one sp to add/update a person record.

The stored procedure sees a value of zero for the ID and it knows to add the
record. Then I set the ID to the value generated by the insert statement.

If the value has a number greater than zero then I just update the record.

Sure, I could do the same thing using null instead of Zero.

Now I am curios if setting an initial value has a design flaw...I may want
to change my methods. Is this a bad practice or just a development preference?

Cheers,

Ben

"Developer" wrote:

> I do this -- get a value from an output param in other places -- so I
> decided to see what was different about this sp; as I recall, it used to
> work correctly.
> For some reason, "RETURN" at the end was commented out... I enabled
> that, loaded the sp, and it appears to work as expected.
>
> Thanks for your help.
>
> Ben wrote:
>
> > The problem is definitly not in the SP. Especially as you capture the .net
> > call and it's results and find it to be 1.
> >
> > So, the problem must be in your .Net code.
> >
> > We do this all the time in a couple apps here. I'll see if I can't find a
> > sample and post.
> >
> > Cheers,
> >
> > Ben
>