Hi all,
I have a MS SQL Server store procedure that receives some data in Json format. When I run the procedure directly from a SQL Studio console windows, it works fine.
When calling the procedure from a RESTfull service it doesn’t work. I have been able to track that the Json data is being received by the procedure, but after that nothing seems to work. The procedure should return an error message if anything goes wrong. I’m getting a blank message.
This is the code of the REST method:
public function actionRadicar() {
$json = $_POST['lote'];
$json = str_replace("\\\"","\"",$json);
$json = utf8_encode($json);
try {
$sql = "EXEC sp_radicar_expedientes @json = :json,@msg = :msg";
$command = Yii::$app->db->createCommand($sql);
$command->bindParam(":json", $json, PDO::PARAM_LOB);
$msg = '';
for ($i=0; $i<100; $i++) $msg.=' ';
$command->bindParam(":msg", $msg, PDO::PARAM_STR | PDO::PARAM_INPUT_OUTPUT,100);
$command->execute();
$result = utf8_encode($msg);
} catch (Exception $ex) {
Yii::trace("Error : ".$e);
return ['Error'=>$ex->message];
}
}
Any idea on what could be wrong?
Regards