PDA

View Full Version : compilation error



pc58
18-05-2004, 20:36
Chao cac ban

Hom nay toi viet thu nay co van de ve oracle 9i cho khong the giai quyet duoc, rat mong cac ban chi giup cho. Truoc nhat xin cam on cac ban that nhieu.


Van de ve loi "error with compilation" trong Oracle 9i:


- Trong các truong hop viet code trong Oracle 9i neu bi loi ve compilation thì thuong chi doc bao là error with compilation, mà khong duoc báo cu the loi nam o dau trong code cua mình viet, toi nghi rang chac minh phai cau hinh lai o cho nao do de oracle the hien ra loi trên mot cách cu the nhung không biet lam nhu the nao ca.

- va nhan tien day, neu co the duoc, Xin nhâncc ban xem giup cho toi tim ra loi "compilation error" trong code sau day nhe, toi xin chiu cung khong biet error o cho nao nua

1) Tao bang nhu sau:

Create table employee
(EmployeeId varchar2(10), Lname varchar2(10), Fname varchar2(10),
PositionID varchar2(10), HireDate Date,
Salary number(10), DeptID varchar2(10));


2) them cac gia tri vào bang nhu sau:

Begin
insert into employee values
('111', 'Smith', 'John', '1', to_date ('04/15/60', 'mm/dd/yy'), 65000, '10');
insert into employee values
('246', 'Houston', 'Larry', '4', to_date ('05/19/67', 'mm/dd/yy'), 10000, '10');
insert into employee values
('123', 'Roberts', 'Sandi', '3', to_date ('12/02/91', 'mm/dd/yy'), 30000, '20');
insert into employee values
('433', 'Dev', 'Derek', '2', to_date ('03/15/95', 'mm/dd/yy'), 55000, '30');
insert into employee values
('543', 'Garner', 'Stanley', '3', to_date ('02/29/96', 'mm/dd/yy'), 15000, '20');
End;


3) Viet mot procedure nhu sau:

CREATE or REPLACE PROCEDURE name_salary
(ID_In IN VARCHAR2 (3),
Lname_Out OUT VARCHAR2(15),
Fname_Out OUT VARCHAR2(15),
Salary_Out OUT NUMBER(10, 2))
IS
BEGIN
SELECT Fname into Fname_Out,
Lname into L_name_Out,
Salary into Salary_Out from Employee
WHERE EmployeeID = ID_In;
DBMS_output.put_line
(Fname_out.name_salary||' '||
Lname_Out.name_salary||' '||
Salary_Out.name_salary);
END;


4) sau khi chay procedure nay thi bi bao loi la "procedure created with Compilation error"


rat mong duoc cac ban quan tam den, va Mot lan nua xin cam oâncc ban truoc nhe.

Than men,

nganminh
23-07-2004, 08:57
CREATE or REPLACE PROCEDURE name_salary
(ID_In IN VARCHAR2 (3),
Lname_Out OUT VARCHAR2(15),
Fname_Out OUT VARCHAR2(15),
Salary_Out OUT NUMBER(10, 2))
IS
BEGIN
SELECT Fname into Fname_Out,
Lname into L_name_Out,
Salary into Salary_Out from Employee
WHERE EmployeeID = ID_In;
DBMS_output.put_line
(Fname_out.name_salary||' '||
Lname_Out.name_salary||' '||
Salary_Out.name_salary);
END;

/
show error

ctr_alt_del
24-07-2004, 08:35
Tôi hiểu ý tưởng của bạn về thủ tục và sửa lại, có lẽ bạn chưa quen debug với PL/SQL
chỉ cần chạy một câu lệnh trong SQLPLUS và show error là biết được vị trí và nguyên nhân lỗi
CREATE or REPLACE PROCEDURE name_salary
(ID_In IN VARCHAR2 ,
Lname_Out OUT VARCHAR2,
Fname_Out OUT VARCHAR2,
Salary_Out OUT NUMBER)
IS
BEGIN
SELECT Fname,Lname, Salary into Fname_Out, Lname_Out, Salary_Out
from Employee
WHERE EmployeeID = ID_In;
DBMS_output.put_line (Fname_out||' '|| Lname_Out||' '|| Salary_Out);
END;
/

nganminh
28-08-2004, 03:56
CREATE or REPLACE PROCEDURE name_salary
(ID_In IN VARCHAR2 ,
Lname_Out OUT VARCHAR2,
Fname_Out OUT VARCHAR2,
Salary_Out OUT NUMBER)
IS
BEGIN
SELECT Fname,Lname, Salary into Fname_Out, Lname_Out, Salary_Out
from Employee
WHERE EmployeeID = ID_In;
DBMS_output.put_line (Fname_out||' '|| Lname_Out||' '|| TO_CHAR(Salary_Out));
END;
/
show err