MySQL is a high-performance open source DBMS, if you want to build a query based on a large and functional requirements for transactions in general applications, MySQL is undoubtedly one of the best alternatives.
Recently, embedded aspects of the communications project, which will use the MySQL 5, a problem encountered in the preparation of the stored procedure, and that is how to build a SQL statement introducing parameters in the stored procedure.
We have limited time, I long story short. For example, we want to build a simple query, the table name is the need to change the dynamic parameters, direct write is certainly not here is not described. That should do, and I also directly on the sections of the code, you will understand a look.
# The stored procedure defines several incoming parameters, the prefix is para_
# this part of the function of the stored procedure is based on a query table name table tbl_name incoming parameters dynamically generated, how many incoming parameters and finished # full match record
the SET tbl_name = CONCAT ( "result_", para_user);
the SET @STMT: = CONCAT ( "the SELECT COUNT (*) the INTO @num_count the FROM", tbl_name
, "the WHERE RNG = '", para_rng
, "' the AND north_latitude = ", para_north
," the AND bck_datetime = ' ", para_datetime
,"'
PREPARE STMT FROM @STMT;
EXECUTE STMT;
Recently, embedded aspects of the communications project, which will use the MySQL 5, a problem encountered in the preparation of the stored procedure, and that is how to build a SQL statement introducing parameters in the stored procedure.
We have limited time, I long story short. For example, we want to build a simple query, the table name is the need to change the dynamic parameters, direct write is certainly not here is not described. That should do, and I also directly on the sections of the code, you will understand a look.
# The stored procedure defines several incoming parameters, the prefix is para_
# this part of the function of the stored procedure is based on a query table name table tbl_name incoming parameters dynamically generated, how many incoming parameters and finished # full match record
the SET tbl_name = CONCAT ( "result_", para_user);
the SET @STMT: = CONCAT ( "the SELECT COUNT (*) the INTO @num_count the FROM", tbl_name
, "the WHERE RNG = '", para_rng
, "' the AND north_latitude = ", para_north
," the AND bck_datetime = ' ", para_datetime
,"'
PREPARE STMT FROM @STMT;
EXECUTE STMT;
Reproduced in: https: //www.cnblogs.com/leaway/archive/2006/08/07/469490.html