一样,同样传一个 null 进去就行了。不过MYSQL存储过程变量不用@开头你可以参考一下手册中的语法说明,自己先试着改一下。然后有什么具体问题可以把你的代码和错误信息一起贴出来。MySQL官方文档 http://dev.mysql.com/doc/refman/5.1/zh/index.html
一样,同样传一个 null 进去就行了。不过MYSQL存储过程变量不用@开头你可以参考一下手册中的语法说明,自己先试着改一下。然后有什么具体问题可以把你的代码和错误信息一起贴出来。MySQL官方文档 http://dev.mysql.com/doc/refman/5.1/zh/index.html
/*--================== get max id ======================*/
WHEN 'sp_getmaxid' THEN
declare sql_max varchar(100);
set sql_max=CONCAT('SELECT IFNULL(MAX(',max_column_name, '''''),) FROM Clients');
prepare sqlstmt from sql_max;
execute sqlstmt;
deallocate prepare sqlstmt;
/*--================== judge the record is exist or not ======================*/
WHEN 'sp_exists' THEN
SELECT 1 into sp_return FROM Clients WHERE ClientId=ClientId ; #use the variable to check the IF EXISTS
IF sp_return <> 0 THEN
set sp_return=1;
END IF;
/*--============== judge the special record is exist or not ==================*/
WHEN 'sp_exists_special' THEN
declare sql_field varchar(200);
set sql_field=CONCAT('SELECT 1 into sp_return FROM Clients WHERE '
,Spcial_field,'='''
,Spcial_field_value,''''
,'; #use the variable to check the IF EXISTS');
/* 下一步不知怎么执行得到的了*/老过不了,谢谢
/*--================== get max id ======================*/
WHEN 'sp_getmaxid' THEN
declare sql_max varchar(100);
set sql_max=CONCAT('SELECT IFNULL(MAX(',max_column_name, '''''),) FROM Clients');
prepare sqlstmt from sql_max;
execute sqlstmt;
deallocate prepare sqlstmt;
错误信息, ,谢谢
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 'DECLARE sql_max varchar(100) ;
set sql_max=CONCAT('SELECT IFNULL(MAX' at line
declare stmt varchar(4000);
set @v_sql = concat('SELECT IFNULL(MAX(', max_column_name, ''''') FROM Clients');
prepare stmt from @v_sql;
execute stmt;现在改为IF 是可以了,不过还有这样的问题提示,原意是想这样的,如果为空的话,就用''代替. 谢谢.
an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''') FROM Clients' at