操縱數據,我創造了我的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