Unknown column "valueToPass" in the "list of fields" MySQL error: 1054

I wrote a stored procedure in mysql for updating. This works fine when you execute it on the mysql command line (via the Mysql editor).

Stored Procedure:

CREATE DEFINER=`root`@`localhost` PROCEDURE `Deduction_Of_PL`( IN P_EMPID VARCHAR(1000) ) BEGIN DECLARE PresentYearPL VARCHAR(1000); set PresentYearPL=(select Present_Year_PL from leave_calculate_pl where employee_id=P_EMPID); IF(PresentYearPL<=0) THEN UPDATE leave_calculate_pl SET Carrie_PL=Carrie_PL-1 where employee_id=P_EMPID; ELSE UPDATE leave_calculate_pl SET Present_Year_PL=Present_Year_PL-1 where employee_id= P_EMPID; END IF; END $$ 

And I call the same stored procedure in PHP, I also pass an input parameter.

 $LeaveTypeID_G=$this->getLeaveTypeId(); $query_G="CALL Deduction_Of_PL($LeaveTypeID_G)"; 

He gives an error like

 Unknown column 'parameter_value' in 'field list' MySQL Error # :1054 

Please let me know where it went wrong and how I can solve it.

+4
source share
3 answers

I just ran into the same problem. I am trying to pass a registered username to a stored procedure in order to write it to the log.

The stored procedure runs fine when I call it directly (from MySQL Workbench) and works fine with PHP when I only passed the date / time. Now that I pass this username as a string, however it has broken.

For me, the fix was to enclose any string parameters in a single quote, something like this:
$query = "CALL $procedure_name ( $date_parameter, '$string_parameter')";

Hope this helps someone else tripping over this.

+1
source

Well, I'm not an sql expert, and I don’t see much PHP code, but the “Unknown column” for me will refer to the column names in the corresponding sql table, or, more precisely, that it can. Do not find the column that you he was told to get into this table. the first place I would look at is the select statement, which asked him to be pulled out of the " Present_Year_PL " column. I found this to be a random senstive, so make sure it exactly matches the column name in the table. the next place I would look is in the statement in which you told him to combine the sorcerer " employee_id ". Now it’s all lowercase, as it was refuted by your previous column name, which was complete while technically legal, (As in the actual table you can have one column in all caps and one at the bottom), usually if all caps are used in the same column name in the table, all column names are executed the same way, and vice versa. this will cause a problem if you have the column "employee identifier" in the table "EMPLOYEE_ID", since the table "actual_id" does not actually exist. also make sure that you do not come up with something like "employeeid" or "employee-id" or even "employee id", as this is easily mistaken when viewing the field name, but will give you an error when receiving.

0
source

pair of pointers:

  • What is the value of php variabele $LeaveTypeID_G ? echo $LeaveTypeID_G; (php)
  • Secondly, does MySql trigger? show triggers; (mysql)
0
source

All Articles