r**e 发帖数: 57 | 1 For some reason, the following code does not work:
DECLARE
Comp_id NUMBER;
Comp_name CHAR(20) := 'ACME SHOWERS';
BEGIN
SELECT company_id_seq.NEXTVAL INTO comp_id
FROM dual;
INSERT INTO company (company_id, company_name)
VALUES (comp_id, comp_name);
END;
It seems that I can not use the Comp_id directly because when I change comp_id
to some real data, it works. | a****c 发帖数: 25 | 2 You need check if your sequence company_id_seq works or not first.
comp_id
【在 r**e 的大作中提到】 : For some reason, the following code does not work: : DECLARE : Comp_id NUMBER; : Comp_name CHAR(20) := 'ACME SHOWERS'; : BEGIN : SELECT company_id_seq.NEXTVAL INTO comp_id : FROM dual; : INSERT INTO company (company_id, company_name) : VALUES (comp_id, comp_name); : END;
| n********a 发帖数: 68 | 3 What is the error msg?
comp_id
【在 r**e 的大作中提到】 : For some reason, the following code does not work: : DECLARE : Comp_id NUMBER; : Comp_name CHAR(20) := 'ACME SHOWERS'; : BEGIN : SELECT company_id_seq.NEXTVAL INTO comp_id : FROM dual; : INSERT INTO company (company_id, company_name) : VALUES (comp_id, comp_name); : END;
|
|