Zrot
Zrot

Reputation: 161

How to call a Stored Procedure from another Stored Procedure in mysql?

Can I do that because it call from function if i use a normal form such as xxx() in mysql? please show me how to do it,thx.

Upvotes: 0

Views: 7949

Answers (2)

aprilleocean
aprilleocean

Reputation: 121

PROCEDURE 1

DROP PROCEDURE IF EXISTS Proc1;
CREATE PROCEDURE Proc1()
BEGIN
  CALL Proc2();
END

PROCEDURE 2

DROP PROCEDURE IF EXISTS Proc2;
CREATE PROCEDURE Proc2()
BEGIN
  SELECT ColumnName  FROM table2;
END

Upvotes: 0

SQLMenace
SQLMenace

Reputation: 135171

In SQL Server it is plain vanilla exec proc statement, here is sql server syntax

create procedure prYourProc
as

-- exec other proc
exec prSomeOtherProc

-- to get return value
declare @var int
exec @var = prSomeOtherProc

Upvotes: 2

Related Questions