Calling a stored procedure within a stored procedure.

Calling a stored procedure within a stored procedure.

Post by Brad Tanne » Thu, 26 Sep 1996 04:00:00



I am working on a stored that calls a stored procedure within itself.
For some reason or another I can't get the thing to work correctly.  Am
I correct in believing that you simply issue the EXEC command to call
another stored procedure??  So far this is what I've got..

CREATE PROCEDURE sp_Pro_Sup_Delete

AS DELETE


FROM tblProducts
        FROM tblProducts p, tblSuppliers s
WHERE p.Table_Suppliers_Counter = s.Table_Suppliers_Counter

To further explain my maddness, I'm trying to perform a cascading delete
on a series of related tables.  In doing this, I have to delete the
foreign keys first before I can delete the primary key.  The procedure
calls another procedure to delete the foreign keys and then deletes the
primary keys.  If you can tell me what I'm not doing correctly I'd
really apreciate it.

BTW, the error I recieve is 156, incorrect syntax near the keyword
'EXEC'.

Thanks in advance..

Brad Tanner

 
 
 

Calling a stored procedure within a stored procedure.

Post by Paul J. LaCross » Fri, 27 Sep 1996 04:00:00


You can't embed an "exec" call in the middle of your delete statement.  You
should start your procs out with an "as begin" right after the parameters
and an "end" at the very end to keep it clear, too!  

> I am working on a stored that calls a stored procedure within itself.
> For some reason or another I can't get the thing to work correctly.  Am
> I correct in believing that you simply issue the EXEC command to call
> another stored procedure??  So far this is what I've got..
> CREATE PROCEDURE sp_Pro_Sup_Delete

> AS DELETE


> FROM tblProducts
>    FROM tblProducts p, tblSuppliers s
> WHERE p.Table_Suppliers_Counter = s.Table_Suppliers_Counter