Ciao a tutti.
da settimane sto cercando di riprende gli output di una stored procedure su Sql Server. ho provato sia con sqlsrv_query, che con i PDO:sqlsrv!
La procedura va a buon fine, ma io non riesco a prendere i parametri di OUTPUT della procedure...
ecco il codice:
Codice PHP:
$sql2 = "{CALL procedura (@In1 =:in1, @In2 = :in2, @In3 = :in3, @In4 = :in4, @Out1 = :out1, @Out2 = :out2, @Out3 = :out3)}";
$stmt2 = $conn->prepare($sql2);
$stmt2->bindValue( ":In1", $in1 );
$stmt2->bindValue( ":In2", $in2);
$stmt2->bindValue( ":In3", $in3);
$stmt2->bindValue( ":In4", $in4 );
$stmt2->bindParam( ":Out1", $Out1,PDO::PARAM_INT );
$stmt2->bindParam( ":Out2", $Out2, PDO::PARAM_INT);
$stmt2->bindParam( ":Out3", $Out3, PDO::PARAM_STR, 4000 );
$stmt2->execute();
echo "<pre>";
print_r ($stmt2->errorInfo());
echo "</pre>";
echo $Out1;
echo $Out2;
echo $Out3;
Poi ho provato così
Codice PHP:
$sql2 = "EXECUTE Procedura $in1, $in2, $in3, $in4, ?, ?, ?";
$stmt2 = $conn->prepare($sql2);
$stmt2->bindParam( 1, $res1, PDO::PARAM_INT);
$stmt2->bindParam( 2, $res2, PDO::PARAM_INT);
$stmt2->bindParam( 3, $res3, PDO::PARAM_STR, 4000);
$stmt2->execute();
echo "<pre>";
print_r ($stmt2->errorInfo());
echo "</pre>";
con quest'ultima la procedura fa tutto ma gli echo dei valori sono nulli. Ho provato anche a creare la variabile prima con $res1 = 0; ecc, ed in quel caso ritorna 0.
Grazie a tutti