Эй, я новичок в PL SQL, и я пытаюсь получить пользовательский ввод и использовать его в процедуре. Теперь я приложил свой код и сообщение об ошибке, которое я получил. Я понял, что я получаю эту ошибку только для строк. Например, JAN FEB и IT_PROG,
SQL> CREATE OR REPLACE PROCEDURE add_job_history AS
2
3 p_employee_id NUMBER (6);
4 p_start_date DATE ;
5 p_end_date DATE ;
6 p_job_id VARCHAR2(10) ;
7 p_department_id NUMBER ;
8
9 BEGIN
10
11 DBMS_OUTPUT.PUT_LINE ('Attempt to insert new record into Job History Database');
12 -- DBMS_OUTPUT.PUT_LINE ('Number ' || &employee_id);
13
14
15
16 p_employee_id := &p_employee_id;
17 p_start_date := &p_start_date;
18 p_end_date := &p_end_date;
19 p_job_id := &p_job_id;
20 p_department_id := &p_department_id;
21
22
23 INSERT INTO job_history(employee_id,start_date,end_date,job_id,department_id)
24 VALUES (p_employee_id,p_start_date,p_end_date,p_job_id,p_department_id); -- try to insert new record
25 COMMIT;
26 END;
27 /
Enter value for employee_id: 103
old 12: -- DBMS_OUTPUT.PUT_LINE ('Number ' || &employee_id);
new 12: -- DBMS_OUTPUT.PUT_LINE ('Number ' || 103);
old 16: p_employee_id := &p_employee_id;
new 16: p_employee_id := 103;
old 17: p_start_date := &p_start_date;
new 17: p_start_date := 03-JAN-06;
old 18: p_end_date := &p_end_date;
new 18: p_end_date := 02-FEB-20;
old 19: p_job_id := &p_job_id;
new 19: p_job_id := IT_PROG;
old 20: p_department_id := &p_department_id;
new 20: p_department_id := 60;
Warning: Procedure created with compilation errors.
SQL> show errors
Errors for PROCEDURE ADD_JOB_HISTORY:
LINE/COL ERROR
-------- -----------------------------------------------------------------
17/3 PL/SQL: Statement ignored
17/22 PLS-00201: identifier 'JAN' must be declared
18/3 PL/SQL: Statement ignored
18/20 PLS-00201: identifier 'FEB' must be declared
19/3 PL/SQL: Statement ignored
19/15 PLS-00201: identifier 'IT_PROG' must be declared