这是我的程序:
CREATE OR REPLACE PACKAGE shop_query_pkg IS
PROCEDURE shop_info_pp
(p_id IN bb_shopper.idshopper%TYPE,
p_firstname OUT bb_shopper.firstname%TYPE,
p_city OUT bb_shopper.city%TYPE,
p_state OUT bb_shopper.state%TYPE,
p_phone OUT bb_shopper.phone%TYPE,
p_email OUT bb_shopper.email%TYPE);
PROCEDURE shop_info_pp
(p_id IN bb_shopper.lastname%TYPE,
p_firstname OUT bb_shopper.firstname%TYPE,
p_city OUT bb_shopper.city%TYPE,
p_state OUT bb_shopper.state%TYPE,
p_phone OUT bb_shopper.phone%TYPE,
p_email OUT bb_shopper.email%TYPE);
END;
/
CREATE OR REPLACE PACKAGE BODY shop_query_pkg IS
PROCEDURE shop_info_pp
(p_id IN bb_shopper.idshopper%TYPE,
p_firstname OUT bb_shopper.firstname%TYPE,
p_city OUT bb_shopper.city%TYPE,
p_state OUT bb_shopper.state%TYPE,
p_phone OUT bb_shopper.phone%TYPE,
p_email OUT bb_shopper.email%TYPE)
IS
BEGIN
SELECT firstname, city, state, phone, email
INTO p_firstname, p_city, p_state, p_phone, p_email
FROM bb_shopper
WHERE idshopper = p_id;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('ID does not exist');
END;
PROCEDURE shop_info_pp
(p_id IN bb_shopper.lastname%TYPE,
p_firstname OUT bb_shopper.firstname%TYPE,
p_city OUT bb_shopper.city%TYPE,
p_state OUT bb_shopper.state%TYPE,
p_phone OUT bb_shopper.phone%TYPE,
p_email OUT bb_shopper.email%TYPE)
IS
BEGIN
SELECT firstname, city, state, phone, email
INTO p_firstname, p_city, p_state, p_phone, p_email
FROM bb_shopper
WHERE lastname = p_id;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('Last name does not exist');
END;
END;
但是当我尝试使用此代码执行我的程序时:
VARIABLE g_fname VARCHAR2
VARIABLE g_city VARCHAR2
VARIABLE g_state VARCHAR2
VARIABLE g_phone VARCHAR2
VARIABLE g_email VARCHAR2
EXECUTE shop_query_pkg.shop_info_pp(23, :g_fname, :g_city, :g_state, :g_phone, :g_email);
PRINT :g_fname
PRINT :g_city
PRINT :g_state
PRINT :g_phone
PRINT :g_email
我收到此错误消息:
BEGIN shop_query_pkg.shop_info_pp(23, :g_fname, :g_city, :g_state, :g_phone, :g_email); END;
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "S36.SHOP_QUERY_PKG", line 11
ORA-06512: at line 1
我认为我的select语句有问题,但我一直在检查它,我无法弄清楚它有什么问题。
这是DESC bb_shopper:
Name Null? Type
IDSHOPPER NOT NULL NUMBER(4)
FIRSTNAME VARCHAR2(15)
LASTNAME VARCHAR2(20)
ADDRESS VARCHAR2(40)
CITY VARCHAR2(20)
STATE CHAR(2)
ZIPCODE VARCHAR2(15)
PHONE VARCHAR2(10)
FAX VARCHAR2(10)
EMAIL VARCHAR2(25)
USERNAME VARCHAR2(8)
PASSWORD VARCHAR2(8)
COOKIE NUMBER(4)
DTENTERED DATE
PROVINCE VARCHAR2(15)
COUNTRY VARCHAR2(15)
PROMO CHAR(1)
是的我已尝试将状态更改为CHAR,我收到相同的消息。
答案 0 :(得分:0)
您必须完全指定VARIABLE类型并添加最大varchar2大小。
如果您使用以下块,它将按预期工作:
(^[A-Z][a-z0-9]+[A-Z]$)|(^[A-Z][a-z0-9]+([A-Z][a-z0-9]+)+$)|(^[A-Z][a-z0-9]+([A-Z][a-z0-9]+)+[A-Z]$)