操纵数据,我创造了我的SQL工作台上的存储过程显示。我正在修改地址的邮编,以格式化'dn35 7tg',即使用户没有插入空格,也可以使用7个字符的邮政编码。Null值当试图在存储过程
首先,我找不到打印变量的康寿屏幕,这不利于我的情况的一种方式。
当运行Call语句
CALL usp_addsupplier('Bobs shopping mania', 'dn465th');
我除了找值订立正确的格式的数据库,但我得到的是PK,空和空列中的输入。
如果某些可能会在正确的方向指向我,我将是巨大的全
谢谢大家。
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `usp_addsupplier`(IN SuppliersName VARCHAR(30), IN SuppliersPostCode VARCHAR(15))
BEGIN
-- Declare the change varables
DECLARE postcode VARCHAR(8) DEFAULT SuppliersPostCode;
SET postcode = SuppliersPostCode;
-- Postcode reformat -----------------------------------------------
-- Change postcode to uppercase
SET postCode = UPPER(postCode);
-- Grabs the first 4 letters and stores them in a new varable
SET new_postcode = LEFT (postCode,4);
-- Adds the space to the first 4 letters
SET new_postcode = new_postcode + ' ';
-- Add the last 3 letters to the new varable
SET new_postcode = new_postcode + RIGHT(postCode,3);
INSERT INTO tblsupplier (SupplierName, SupplierPostCode VALUES (new_name, new_postcode));
END
你为什么要声明参数'SupplierPostCode'的类型为'VARCHAR(15)',那么只需将其分配给''VARCHAR(8)''类型的'postcode'变量来丢失一半数据呢? – eggyal