Accesing Mssql Procedure

I am trying to execute MSSQL procedure name "AppointmentCancel" but “Invalid parameter number: parameter was not defined” error is returned

Here is my code




$rc = null;


            $db = Yii::app()->db;

            $command = $db->createCommand('exec :rc = AppointmentCancel :appointment_id, :reason, :comments');

            $command->bindValue(':appointment_id', $apptID, SQLINT4);

            $command->bindValue(':reason', $reason, SQLVARCHAR);

            $command->bindValue(':comments', $comments, SQLVARCHAR);

            $command->bindParam(':rc', $rc, SQLINT4);

            $rows = $command->queryAll();



What is wrong with this code? could you please help. thanks in advance

Use input-output or output parameter




$rc = null;


            $db = Yii::app()->db;

            $command = $db->createCommand('exec AppointmentCancel :appointment_id, :reason, :comments, :rc ');

            $command->bindValue(':appointment_id', $apptID, SQLINT4);

            $command->bindValue(':reason', $reason, SQLVARCHAR);

            $command->bindValue(':comments', $comments, SQLVARCHAR);

            $command->bindParam(':rc', $rc, PDO::PARAM_INT | PDO::PARAM_INPUT_OUTPUT, 1);

            $rows = $command->queryAll();