This is a procedure to update multiple table's data in oracle , as compiler is showing Error: ORA-00922: missing or invalid option error
This is a procedure to update multiple table's data in oracle , as compiler is showing Error: ORA-00922: missing or invalid option error
这是一个在 oracle 中更新多个 table 数据的程序,不知道我在哪里出错,因为编译器显示错误:ORA-00922:丢失或无效选项错误,请帮助
我检查了我认为正确的语法。
create or replace procedure add_Course(
p_title_name in course.tilte%type,
p_course_id in course.course_id%type,
p_credits in course.credits%type,
p_program_id in PROGRAMS.program_id%type,
p_grade in PROGRAMS.grade%type,
p_room_type in classroom.room_type%type,
p_room_no in classroom.room_no%type,
p_sec_id in section.sec_id%type,
p_semester in section.semester%type,
p_year in section.year%type,
p_building in section.building%type)
as
cnt number;
begin
select count(*) into cnt from course where title=p_title_name;
if cnt = 1 then
update course set credits=p_credits where title=p_title_name;
update program set program_id=p_program_id,semester=p_semester,year=p_year,grade=p_grade where course_id=p_course_id;
update classroom set room_type=p_room_tpe, room_no=p_room_no, building=p_building where COURSE_TYPE=p_course_type;
update section set sec_id=p_sec_id, semester=p_semestr, year=p_year,BUILDING=p_building,room_type=p_room_type where course_id=p_couse_id;
dbms_output.put_line('course detils is changed');
commit;
else
dbms_output.put_line('couser dose not exist');
end if;
end;
创建过程时(有错误),根据您使用的工具,查看错误。例如,在 SQL*Plus:
SQL> create or replace procedure add_Course(
2 p_title_name in course.tilte%type,
3 p_course_id in course.course_id%type,
4 p_credits in course.credits%type,
5 p_program_id in PROGRAMS.program_id%type,
6 p_grade in PROGRAMS.grade%type,
7 p_room_type in classroom.room_type%type,
8 p_room_no in classroom.room_no%type,
9 p_sec_id in section.sec_id%type,
10 p_semester in section.semester%type,
11 p_year in section.year%type,
12 p_building in section.building%type)
13 as
14 cnt number;
15 begin
16 select count(*) into cnt from course where title=p_title_name;
17 if cnt = 1 then
18 update course set credits=p_credits where title=p_title_name;
19 update program set program_id=p_program_id,semester=p_semester,year=p_year,grade=p_grade where course_id=p_course_id;
20 update classroom set room_type=p_room_tpe, room_no=p_room_no, building=p_building where COURSE_TYPE=p_course_type;
21 update section set sec_id=p_sec_id, semester=p_semestr, year=p_year,BUILDING=p_building,room_type=p_room_type where course_id=p_couse_id;
22 dbms_output.put_line('course detils is changed');
23 commit;
24
25 else
26 dbms_output.put_line('couser dose not exist');
27
28 end if;
29 end;
30 /
Warning: Procedure created with compilation errors.
SQL> show err
Errors for PROCEDURE ADD_COURSE:
LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0 PL/SQL: Compilation unit analysis terminated
2/20 PLS-00201: identifier 'COURSE.TILTE' must be declared
SQL>
适用于任何地方的选项是 select 来自 user_erros
的信息:
SQL> select * from user_errors where name = 'ADD_COURSE';
NAME TYPE SEQUENCE LINE POSITION
------------------------------ ------------ ---------- ---------- ----------
TEXT
--------------------------------------------------------------------------------
ATTRIBUTE MESSAGE_NUMBER
--------- --------------
ADD_COURSE PROCEDURE 1 2 20
PLS-00201: identifier 'COURSE.TILTE' must be declared
ERROR 201
ADD_COURSE PROCEDURE 2 0 0
PL/SQL: Compilation unit analysis terminated
ERROR 0
SQL>
这应该可以帮助您修复大多数错误。有不明白或无法解决的地方说说。
有些语法错误,
您的代码中有几个拼写错误:p_semestr、p_couse_id、p_room_tpe。当然,在您将这些更正为实际参数名称之前,您的代码不会编译
这是一个在 oracle 中更新多个 table 数据的程序,不知道我在哪里出错,因为编译器显示错误:ORA-00922:丢失或无效选项错误,请帮助
我检查了我认为正确的语法。
create or replace procedure add_Course(
p_title_name in course.tilte%type,
p_course_id in course.course_id%type,
p_credits in course.credits%type,
p_program_id in PROGRAMS.program_id%type,
p_grade in PROGRAMS.grade%type,
p_room_type in classroom.room_type%type,
p_room_no in classroom.room_no%type,
p_sec_id in section.sec_id%type,
p_semester in section.semester%type,
p_year in section.year%type,
p_building in section.building%type)
as
cnt number;
begin
select count(*) into cnt from course where title=p_title_name;
if cnt = 1 then
update course set credits=p_credits where title=p_title_name;
update program set program_id=p_program_id,semester=p_semester,year=p_year,grade=p_grade where course_id=p_course_id;
update classroom set room_type=p_room_tpe, room_no=p_room_no, building=p_building where COURSE_TYPE=p_course_type;
update section set sec_id=p_sec_id, semester=p_semestr, year=p_year,BUILDING=p_building,room_type=p_room_type where course_id=p_couse_id;
dbms_output.put_line('course detils is changed');
commit;
else
dbms_output.put_line('couser dose not exist');
end if;
end;
创建过程时(有错误),根据您使用的工具,查看错误。例如,在 SQL*Plus:
SQL> create or replace procedure add_Course(
2 p_title_name in course.tilte%type,
3 p_course_id in course.course_id%type,
4 p_credits in course.credits%type,
5 p_program_id in PROGRAMS.program_id%type,
6 p_grade in PROGRAMS.grade%type,
7 p_room_type in classroom.room_type%type,
8 p_room_no in classroom.room_no%type,
9 p_sec_id in section.sec_id%type,
10 p_semester in section.semester%type,
11 p_year in section.year%type,
12 p_building in section.building%type)
13 as
14 cnt number;
15 begin
16 select count(*) into cnt from course where title=p_title_name;
17 if cnt = 1 then
18 update course set credits=p_credits where title=p_title_name;
19 update program set program_id=p_program_id,semester=p_semester,year=p_year,grade=p_grade where course_id=p_course_id;
20 update classroom set room_type=p_room_tpe, room_no=p_room_no, building=p_building where COURSE_TYPE=p_course_type;
21 update section set sec_id=p_sec_id, semester=p_semestr, year=p_year,BUILDING=p_building,room_type=p_room_type where course_id=p_couse_id;
22 dbms_output.put_line('course detils is changed');
23 commit;
24
25 else
26 dbms_output.put_line('couser dose not exist');
27
28 end if;
29 end;
30 /
Warning: Procedure created with compilation errors.
SQL> show err
Errors for PROCEDURE ADD_COURSE:
LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0 PL/SQL: Compilation unit analysis terminated
2/20 PLS-00201: identifier 'COURSE.TILTE' must be declared
SQL>
适用于任何地方的选项是 select 来自 user_erros
的信息:
SQL> select * from user_errors where name = 'ADD_COURSE';
NAME TYPE SEQUENCE LINE POSITION
------------------------------ ------------ ---------- ---------- ----------
TEXT
--------------------------------------------------------------------------------
ATTRIBUTE MESSAGE_NUMBER
--------- --------------
ADD_COURSE PROCEDURE 1 2 20
PLS-00201: identifier 'COURSE.TILTE' must be declared
ERROR 201
ADD_COURSE PROCEDURE 2 0 0
PL/SQL: Compilation unit analysis terminated
ERROR 0
SQL>
这应该可以帮助您修复大多数错误。有不明白或无法解决的地方说说。
有些语法错误,
您的代码中有几个拼写错误:p_semestr、p_couse_id、p_room_tpe。当然,在您将这些更正为实际参数名称之前,您的代码不会编译