Home > database >  Stored procedure Insert statement how to deal with receiving a Varchar value
Stored procedure Insert statement how to deal with receiving a Varchar value

Time:10-01

 how to solve this problem bosses, main this quote 

CodePudding user response:

CodePudding user response:

such an error

CodePudding user response:

Come on, you big

CodePudding user response:

your incoming parameters string to use single quotes, the most important thing is that some string contains ";" , leading to the MySQL server error (MySQL server parse to the ";" Will be considered to be the end of a statement).
The test results are as follows:
Correct results:


Your problems:

Solution:



CodePudding user response:

The
reference 3 floor qq_327 response:
come on,,

Want to ask next program is quoted from the, never understand

CodePudding user response:

String enclosed in sound or double quotation marks, single or double quotation marks within the string plus \ escape before
Have nothing to do with whether the parameters of the stored procedure, the string is the standard

CodePudding user response:

As for receiving data, of course, there is no single quotes, single quotes is tell MySQL this is a string, and mark the beginning and end of the string
This where there is need to struggle

CodePudding user response:

In addition, you are all parameters, why not just use parameters, and to spell a SQL to perform?
Direct reference parameters to do the insert line:
Insert into score (name, subject,...
Values (@ SQLC, studentname,...

Parameter, studentname here and, of course, the column names in the table is the same, in this statement to won't be a problem, but if put conditions or in the query, is a matter of priority groups, you will can't figure out what is in the column or parameter, so usually is suggested that the parameter name and the table column names don't like

CodePudding user response:

refer to the eighth floor ZJCXC response:
in addition, you are all parameters, why not just use parameters, and to spell a SQL to perform?
Direct reference parameters to do the insert line:
Insert into score (name, subject,...
Values (@ SQLC, studentname,...

Parameter, studentname here and, of course, the column names in the table is the same, in this statement to won't be a problem, but if put conditions or in the query, is a matter of priority groups, you will can't figure out what is in the column or parameter, so usually is suggested that the parameter name and the table column names don't like

Writes, the parameter is not no quotes, insert an error

CodePudding user response:

refer to the eighth floor ZJCXC response:
in addition, you are all parameters, why not just use parameters, and to spell a SQL to perform?
Direct reference parameters to do the insert line:
Insert into score (name, subject,...
Values (@ SQLC, studentname,...

Parameter, studentname here and, of course, the column names in the table is the same, in this statement to won't be a problem, but if put conditions or in the query, is a matter of priority groups, you will can't figure out what is in the column or parameter, so usually is suggested that the parameter name and the table column names don't like

Can understand a bit poor, write an example, thank you for your bosses

CodePudding user response:

Program if send it directly to the variable need not quotes, if there is to use the "+ +" variable resolution, must be single quotes,
  • Related