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)
 getting an output value in a cursor

Author  Topic 

Kappy
Starting Member

30 Posts

Posted - 2001-12-03 : 16:07:36
Hi-

I am working on a procedure that uses a cursor to pass values to a sproc. The sproc that I am passing values to creates another value that I need. How do I get this value?

Example:
exec espIncident 1, --site id
0, --Incident Id
12345 --Customer Id

The incident Id is created as the procedure is run, and I need that value to continue the rest of my procedure.

I hope I have explained this correctly...

Thanks!



efelito
Constraint Violating Yak Guru

478 Posts

Posted - 2001-12-03 : 16:38:25
You need to define the output variable as part of the procedure declaration.

create procedure espIncident
@invar int,
@outvar int OUTPUT
AS
select @outvar = @invar * 2
return

Then you can get the variable back when you run the proc

declare @espIncidentOutput
exec espIncident 5, @espIncidentOutput OUTPUT
select @espIncidentOutput


Jeff Banschbach
Consultant, MCDBA


Edited by - efelito on 12/03/2001 16:38:48
Go to Top of Page
   

- Advertisement -