MySql存储过程在某列的末尾插入空格

时间:2011-06-16 15:41:06

标签: php mysql

MySQL版本:5.0.77。当我使用一个特定列运行我的存储过程时,它会在字符数据的末尾插入一堆空格IF并且仅在我插入的列的值在20到25之间(可能是19到24之类的东西)类似的。我没有完全缩小它。这是我的存储过程:

DELIMITER $$
DROP PROCEDURE IF EXISTS sp_addBuild$$
CREATE PROCEDURE sp_addBuild
(
IN product INT,
IN view VARCHAR(40),
IN buildnum VARCHAR(30),
IN userName VARCHAR(30),
OUT pk_build INT
)
BEGIN
DECLARE buildStatus VARCHAR(30);
SET buildStatus = 'in progress';
INSERT INTO inf_build (
fk_product_1,
view_name,
build_number,
build_date,
build_status,
build_user
) VALUES(
product,
view,
buildnum,
NOW(),
buildStatus,
userName
);
SET pk_build=(SELECT LAST_INSERT_ID());
END$$
DELIMITER ;

正在停止调用的调用是从php调用的,如下所示:

connect_to_db();

//Add a row in the database for this build
$query = "CALL sp_addBuild('" . $product . "','" . $view . "','" . $buildNumber . "','" . $user->username . "',@pk_build)";
mysql_query($query) or die(mysql_error());

有问题的行来自$ view,我验证过它没有附加任何空格。实际上,表中显示的结果比表允许的字符多。这是表格:

mysql> describe inf_build;
+--------------+-------------+------+-----+-------------+----------------+
| Field        | Type        | Null | Key | Default     | Extra          |
+--------------+-------------+------+-----+-------------+----------------+
| pk_build     | int(10)     | NO   | PRI | NULL        | auto_increment | 
| fk_product_1 | int(10)     | YES  | MUL | NULL        |                | 
| view_name    | varchar(40) | YES  |     | NULL        |                |
| build_number | varchar(30) | YES  |     | NULL        |                | 
| build_date   | datetime    | YES  |     | NULL        |                | 
| build_status | varchar(20) | NO   |     | in progress |                | 
| build_user   | varchar(30) | YES  |     | NULL        |                | 
+--------------+-------------+------+-----+-------------+----------------+

另一个奇怪的事情是,无论添加什么内容,都会在表格底部显示一行。

有人有任何线索吗?

谢谢!

0 个答案:

没有答案