英文:
Creating a procedure that inserts into 2 tables with a relationship
问题
我明白有很多类似的问题,但由于这是我的学校项目,它需要遵循他们教给我们的相同技术,其他答案并不是我要找的。
我的代码:
CREATE or REPLACE PROCEDURE add_hire1 (hire_no_in IN NUMBER, date_hired_in IN DATE, drop_off_in IN DATE, fk1_customer_id_in IN NUMBER, fk2_charge_no_in NUMBER, charge_no_in NUMBER, final_cost_in NUMBER)
AS
BEGIN
INSERT INTO hire(hire_no, date_hired, drop_off, fk1_customer_id, fk2_charge_no)
VALUES (hire_no_in, date_hired_in, drop_off_in, fk1_customer_id_in, fk2_charge_no_in);
INSERT INTO charge(charge_no, final_cost)
VALUES(charge_no_in, final_cost_in);
END add_hire1;
这是返回的错误信息:
ORA-24344: 编译错误成功
ORA-06512: 在“SYS.WWV_DBMS_SQL_APEX_190100”第590行
ORA-06512: 在“SYS.DBMS_SYS_SQL”第1658行
ORA-06512: 在“SYS.WWV_DBMS_SQL_APEX_190100”第576行
ORA-06512: 在“APEX_190100.WWV_FLOW_DYNAMIC_EXEC”的第2033行
由于我们刚刚学会了如何在一个表中执行此操作,我只是按照原始代码的格式添加了第二个表,所以我不确定是否正确,或者是否只有一些小错误。任何帮助都将不胜感激,谢谢。
英文:
I understand that there is a lot of questions like this one but as it is for my school project it needs to follow the same techniques that they have taught us and the other answers aren't quite what i'm looking for.
My code:
CREATE or REPLACE PROCEDURE add_hire1 (hire_no_in IN NUMBER, date_hired_in IN DATE, drop_off_in IN DATE, fk1_customer_id_in IN NUMBER, fk2_charge_no_in IN NUMBER,
charge_no_in, final_cost_in)
AS
BEGIN
INSERT INTO hire(hire_no, date_hired, drop_off, fk1_customer_id, fk2_charge_no)
VALUES (hire_no_in, date_hired_in, drop_off_in, fk1_customer_id_in, fk2_charge_no_in);
INSERT INTO charge(charge_no, final_cost)
VALUES(charge_no_in, final_cost_in);
END add_hire1;
This is the error returned:
ORA-24344: success with compilation error
ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_190100", line 590
ORA-06512: at "SYS.DBMS_SYS_SQL", line 1658
ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_190100", line 576
ORA-06512: at "APEX_190100.WWV_FLOW_DYNAMIC_EXEC", line 2033
As we have just been taught how to do it with one table I have just added the second table in the same format as the original code so I'm not sure if it's correct or if there's just a few small errors.
Any help appreciated,
Thanks.
答案1
得分: 2
ORA-24344表示编译错误。如果您正在使用类似SQL Developer的工具,它应该会显示编译错误。但您始终可以像这样自己找到它们:
select * from user_errors
where name = 'ADD_HIRE1'
如果我们有一个已编译的包,然后我们对其进行了更改,现在它无法编译,我们知道需要关注我们所做的更改。在这种情况下,我们可以看到您刚刚添加的两个参数...
,
charge_no_in, final_cost_in)
AS
...与其他参数的声明方式不同:
, fk1_customer_id_in IN NUMBER, fk2_charge_no_in IN NUMBER
这种差异是解决代码的关键线索。
英文:
ORA-24344 signifies compilation errors. If you are using a tool like SQL Developer it should show you the compilation errors. But you can always find them for yourself like this:
select * from user_errors
where name = 'ADD_HIRE1'
If we had a package which compiled then we changed it and now it doesn't compile we know we need to focus on the changes we made. In this case we can see that the two parameters you've just added …
,
charge_no_in, final_cost_in)
AS
… are not declared in the same way as the other parameters:
, fk1_customer_id_in IN NUMBER, fk2_charge_no_in IN NUMBER
That difference is a big clue as to how you need to fix your code.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论