• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error in Model to Call Stored Procedure MYSQL

#1
I have the following error when executing an SP in my model:

Code:
A Database Error Occurred
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?,?,?,?,?,?,?,?,?,?,?,@estado,@msg)' at line 1
CALL sp_nuevo_usuario_no_pre_cargado(?,?,?,?,?,?,?,?,?,?,?,@estado,@msg)
Filename: models/Welcome_model.php
Line Number: 237

And this is my model:


Code:
public function nuevoUsuarioNoPreCargado($nombres = null, $apellidos = null, $codigo = null, $rut = null, $correo = null, $fecha_nacimiento = null, $sexo = null, $privilegios_id = null, $codigo_jefe = -1, $password = null, $hash = null){
        
        $sql = 'CALL sp_nuevo_usuario_no_pre_cargado(?,?,?,?,?,?,?,?,?,?,?,@estado,@msg)';
        $query = $this->db->query($sql,array($nombres,$apellidos,$codigo,$rut,$correo,$fecha_nacimiento,$sexo,$privilegios_id,$codigo_jefe,$password,$hash));

        $sql_2 = 'SELECT @estado AS estado, @msg AS msg';
        $query_2 = $this->db->query($sql);

        if($query != null && $query != false && $query_2 != null && $query_2 != false){
            return $query_2->row()->estado;
        }else{
            return false;
        }

    }

But if, i remove the @ from the output parameter, this is the response:

Code:
A Database Error Occurred
Error Number: 1414
OUT or INOUT argument 12 for routine be_fsc.sp_nuevo_usuario_no_pre_cargado is not a variable or NEW pseudo-variable in BEFORE trigger
CALL sp_nuevo_usuario_no_pre_cargado('asdas','dasda','123456','44231234','[email protected]','2019-05-09','Masculino','2',-1,'123456789','9946c3cff71715a3f2d99ad6642c121b0a191edc',estado,msg)
Filename: models/Welcome_model.php
Line Number: 234



The Stored Procedure Work fine in mysql shell and passing parameter manually.
Reply

#2
Should this be like

PHP Code:
$query_2 $this->db->query($sql);

$query_2 $this->db->query($sql_2); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.