Kein
Kein

Reputation: 996

Symfony doctrine and stored procedure

I try to learn symfony by this tutorial

And is very good guide. But know im want to create stored procedure. And how i can describe procedures in shema yaml files? Because when i try to ./symfony doctrine:build --all -and-load - doctrine drop my database and i lose all my procedures

Upvotes: 0

Views: 2595

Answers (2)

guillaume
guillaume

Reputation: 11

hy, I have a procedure under sql server.

ALTER PROCEDURE [dbo].[TEST]
-- Variables d'entrée
@p_ENL_I_ID                 int,
-- Variables de retour
@p_RETURN_STATUS            int output
AS
BEGIN
if @p_ENL_I_ID >5   
begin
    SET @p_RETURN_STATUS= 6
end
else
begin
    SET @p_RETURN_STATUS=2
end
END

and my code for call this procédure :

$query = "{CALL TEST(:p_ENL_I_ID,  :p_RETURN_STATUS) }";
$rsm = new ResultSetMapping;
$nativeQuery = $this->entityManager->createNativeQuery($query, $rsm);
$nativeQuery->setParameters(array('p_ENL_I_ID'=> 8 ,'p_RETURN_STATUS' => '' ));
$result= $nativeQuery->getResult();

the procedure works but I have an error : exception occurred in the driver: SQLSTATE[IMSSP]: The active result for the query contains no fields

how to retrieve return variable @p_RETURN_STATUS ?

Thank ! Cédric

Upvotes: 0

Maerlyn
Maerlyn

Reputation: 34105

You cannot describe stored procedures in doctrine's yaml schema. However, you can do that in sql, and with the help in this post from Jonathan Wage you can execute that sql after loading your fixtures.

Upvotes: 3

Related Questions