How to intercept a return code from sc_exec

I need to intercept a potential error code in the invocation of a stored procedure inside a button event:


$sql="CALL PROVAVERNICIATURA(" . {NUMEROPROVA} . )";
sc_exec(,$sql);

How can I ge the return code from the the call invocation ?

I’ve tried also this:


$sql="CALL PROVAVERNICIATURA(" . {NUMEROPROVA} . )";
sc_select(ret,$sql);
if($ret === false)
{
echo "<script>alert('Ooops!' . $ret);</script>";
}

withotu any success.

If the stored procedure fails I am not able to get the return code from the database but I simply get a generic

db2_exec execution failed.

Set your variables by reference. and get them with @myvar in your select.