Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to call Stored Procedure from stored procedure

Status
Not open for further replies.

ericksoda

Programmer
Oct 22, 2001
60
US
I need to process through a table of people, for each person execute a stored procedure and then store the results of the stored procedure in another (temporary) table.


the stored procedure is:
cusAging GuarantorId, getdate(),NULL,NULL
which returns a row

So, how do I process each row of Guarantor, call the stored procedure, and then get the columns of the returned row and write into another table?

Thanks for any help!

David
 
Ok, I got this far:
+++++++++++++++++++++++++++++++++++++++++++++++
Create Table #tmp_table
(
InsDeposit money,
PatDeposit money,
InsBucket0 money,
InsBucket1 money,
InsBucket2 money,
InsBucket3 money,
InsBucket4 money,
PatBucket0 money,
PatBucket1 money,
PatBucket2 money,
PatBucket3 money,
PatBucket4 money,
InsBalance money,
PatBalance money,
GuarantorId int
)

declare @GuarId int
declare @fcDate varchar(20)

SET @fcDate = '10/30/2003' --getdate()

Declare fcGuarList cursor FOR
Select GuarantorId
FROM Guarantor

OPEN fcGuarList
Fetch NEXT FROM fcGuarList
INTO @GuarId

WHILE @@FETCH_STATUS = 0
Begin
insert #tmp_table
exec cusaging @GuarId,@fcdate,NULL,NULL
Fetch NEXT FROM fcGuarLis
end
++++++++++++++++++++++++++++++++++++++++

The only problem now is that the cusaging routine doesn't return the @GuarId that I pass in. And I can't change the behavior, since that is provided by the application vendor. Is there anyway to add the value of @GuarId to the row returned by cusAging?

Thanks

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top