How to call multiple procedure from single procedure in my sql

Posted by Jayakumars under Sql Server on 8/23/2015 | Points: 10 | Views : 390 | Status : [Member] [MVP] | Replies : 3
Hi

Experts

How to merge and data retrieve Multiple procedure




Procedure 1

select shareno,date as Dat,
Recptamt,Payamt,openingbalance as obrecpt,0 as obpay ,
0 as opnbal, 0 as cb1,0 as cb2 from `dbbank`.`sharledg`
where shareno=_selectid and date between '01-06-2015' and '18-08-2015' group by date ;



Procedure 2

select shareno,date,0,0,0,0,openingbalance as opnbal,0 as cb1,0 as cb2 from `dbbank`.`sharledg`
where shareno=_selectid and date < '01-06-2015' order by date desc limit 1;

Mark as Answer if its helpful to you


Responses

Posted by: Sheonarayan on: 8/23/2015 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
You can call stored procedure using EXEC keyword. In below code snippet, you can see that I am accepting two parameters into CallMultiProcedure stored procedure that is being used into LoadPersonalDetails and GetAllPersonalDetails stored procedure respectively.

CREATE PROCEDURE CallMultiProcedure
@Age int,
@personalDetailsId int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

EXEC LoadPersonalDetails @Age
EXEC GetAllPersonalDetails @personalDetailsId
END

Here LoadPersonalDetails and GetAllPersonalDetails stored procedure accepts one parameter. Multiple parameters can be passed separated by comma (,).


Regards,
Sheo Narayan
http://www.dotnetfunda.com

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 8/23/2015 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi

Sheo

I am using mysql so working procedure already but when i call main procedure execute first procedure only.

How to fixed this?

Mark as Answer if its helpful to you

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 8/25/2015 [Member] [MVP] Platinum | Points: 25

Up
0
Down
post us how you are calling two stored procedures in main stored procedure (the MySQL code)...

So that we can guide you to fix the issue

http://stackoverflow.com/questions/11000802/calling-a-stored-procedure-in-a-stored-procedure-in-mysql

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response