MySQL存储过程语法错误

时间:2018-03-20 04:24:02

标签: mysql stored-procedures navicat

我的mysql版本是5.5,当运行这个mysql存储过程时,它会返回此错误。

代码:

CREATE DEFINER = CURRENT_USER PROCEDURE `getReceiptNumber`(IN bankcode 
varchar,IN receipttype varchar,OUT seq int)
BEGIN
    update receipt_number 
    set seq_number = (seq_number + 1) 
    where bank_code = bankcode and receipt_type = receipttype;
    select seq_number from receipt_number where bank_code = bankcode and 
receipt_type = receipttype into seq; 
END;

表格结构:

CREATE TABLE `receipt_number` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `bank_code` varchar(255) DEFAULT NULL,
  `cur_date` varchar(255) DEFAULT NULL,
  `cur_year` int(11) DEFAULT NULL,
  `receipt_type` varchar(255) DEFAULT NULL,
  `seq_number` int(5) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

错误:

[Err] 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 'IN receipttype varchar,OUT seq int) BEGIN update receipt_number set seq_nu' at line 1

1 个答案:

答案 0 :(得分:2)

您没有在参数varchar中提及

的大小

尝试以下代码。

$_POST['title']