| Author |
Topic |
|
Sean_B
Posting Yak Master
111 Posts |
Posted - 2007-03-23 : 10:10:03
|
| Hi,I hope someone can help.I've written a stored procedure that returns a value via an output parameter.I'm calling the stored procedure in an sql session is a loop, and it passes the value back correctly the first time, but all subsequent calls the output parameter appears to have the same value. I believe that I'm making some very basic mistake, but I can't work it out.Here's how I'm calling the stored procedure several timesbegindeclare @instrumentid int exec GetInstrumentId 'OFX,AUDCHF,p,1,2007-03-20 16:54:21.843,2007-06-20,100.1', @instrumentid output;select @instrumentidexec GetInstrumentId 'OFX,AUDUSD,c,2,2007-03-20 16:54:21.843,2007-06-20,100.2', @instrumentid output;select @instrumentidexec GetInstrumentId 'OFX,AUDCHF,p,3,2007-03-20 16:54:21.843,2007-06-20,100.3', @instrumentid output;select @instrumentidendAnd this is the start of the stored procedureCreate PROCEDURE [dbo].[GetInstrumentId] (@Ticket varchar(250), @InstrumentId int output)ASIf I call the stored procedure once it gives the corect output, if I call it several times the output parameter (@instrumentid ) never changes.Sean |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-03-23 : 10:11:35
|
| Looks ok.Trydeclare @instrumentid int exec GetInstrumentId 'OFX,AUDCHF,p,1,2007-03-20 16:54:21.843,2007-06-20,100.1', @instrumentid output;select @instrumentidselect @instrumentid = nullexec GetInstrumentId 'OFX,AUDUSD,c,2,2007-03-20 16:54:21.843,2007-06-20,100.2', @instrumentid output;select @instrumentidselect @instrumentid = nullexec GetInstrumentId 'OFX,AUDCHF,p,3,2007-03-20 16:54:21.843,2007-06-20,100.3', @instrumentid output;select @instrumentid==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
Sean_B
Posting Yak Master
111 Posts |
Posted - 2007-03-23 : 10:16:39
|
| Thanks a lot, setting the parameter to null does the trick.Sean |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2007-03-23 : 11:30:28
|
Huh?USE NorthwindGOCREATE PROC mySproc99 @x int, @y char(1) OUTPUTASIF @x = 1 SET @y = 'a'IF @x = 2 SET @y = 'b'IF @x = 3 SET @y = 'c'RETURNGODECLARE @y char(1)EXEC mySproc99 1, @y OUTPUTSELECT @yEXEC mySproc99 2, @y OUTPUTSELECT @yEXEC mySproc99 3, @y OUTPUTSELECT @yGODROP PROC mySproc99GO You have something else going onBrett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
|
|
|