创建一个名为insert_credit
的过程,以通过将5个输入作为参数传递到credit_card
表中。
程序名称:insert_credit
输入参数:credit_id with data type as number,credit_card_number with data type as varchar,credit_card_expire with data type as varchar,holder_name with data type as varchar and card_type with data type as varchar
使用的表:credit_card
我写了这个:
CREATE OR REPLACE PROCEDURE insert_credit(
p_credit_id IN credit_card.credit_id%TYPE,
p_credit_card_number IN credit_card.credit_card_number%TYPE,
p_credit_card_expire IN credit_card.credit_card_expire%TYPE,
p_holder_name IN credit_card.holder_name%TYPE,
p_card_type IN credit_card.card_type%TYPE)
IS
BEGIN
INSERT INTO credit_card ("credit_id", "credit_card_number", "credit_card_expire", "holder_name","card_type")
VALUES (p_credit_id, p_credit_card_number,p_credit_card_expire,
p_holder_name,p_card_type);
COMMIT;
END;
/
执行时,我得到:
“警告:由于编译错误而创建的过程。”
答案 0 :(得分:0)
如果要调试过程,可以像匿名块一样运行它,并声明所有输入参数。
/*CREATE OR REPLACE PROCEDURE insert_credit(
p_credit_id IN credit_card.credit_id%TYPE,
p_credit_card_number IN credit_card.credit_card_number%TYPE,
p_credit_card_expire IN credit_card.credit_card_expire%TYPE,
p_holder_name IN credit_card.holder_name%TYPE,
p_card_type IN credit_card.card_type%TYPE)
IS */
declare
p_credit_id credit_card.credit_id%TYPE := somevalue
...
..
...
P_card_type
BEGIN
INSERT INTO credit_card ("credit_id", "credit_card_number", "credit_card_expire", "holder_name","card_type")
VALUES (p_credit_id, p_credit_card_number,p_credit_card_expire,
p_holder_name,p_card_type);
COMMIT;
END;
现在,您将能够获得出现错误的行。程序段运行无误后,您可以删除声明部分并取消注释注释的代码。
答案 1 :(得分:0)
CREATE OR REPLACE
PROCEDURE insert_credit(
credit_id IN credit_card.id%TYPE,
credit_card_number IN credit_card.card_number%TYPE,
credit_card_expire IN credit_card.card_expire%TYPE,
holder_name IN credit_card.name%TYPE,
card_type IN credit_card.cc_type%TYPE) AS
BEGIN
INSERT INTO credit_card(id,card_number,card_expire,name,cc_type)
VALUES(credit_id,credit_card_number,credit_card_expire,holder_name,card_type);
END insert_credit;
/