2013-01-24 3 views
-3

누군가이 PSQL에 컴파일 오류가 발생하는 이유를 알려주십시오.오라클 - PSQL 컴파일 오류

set serveroutput on 
Create or replace function get_warehouse_location(Name in Customer.Name%type) 
return w.location %type as 
wLocation  warehouse.Location %type; 
begin 
select warehouse.location 
into wLocation 
from Customer c, Warehouse w 
where cName= 'Finch' 
and warehouse.address='  '; 
return (Location); 
end; 
+1

구문 오류 란 무엇입니까? 첫 번째 홍당무에서, 당신은 어디에서나 정의한 변수가 아닌'location'을 반환합니다. 아마도'return wLocation'을 의미 할 것입니다. 일단 그것을 고치면'SELECT'가 너무 많은 행을 반환하기 때문에 런타임 오류가 발생할 것을 강력히 기대합니다. 'customer' 테이블과'warehouse' 테이블 사이에 데카르트 조인을하고 있으므로 정확하게 1 행을 리턴 할 수는 없습니다. –

답변

0

유형을 호출하는 방법에 최소한 문제가 있습니다. table.field % TYPE이어야합니다. 공백이 없어야합니다.

set serveroutput on 
Create or replace function get_warehouse_location(Name in Customer.Name%type) 
return w.location%type as 
wLocation  warehouse.Location%type; 
begin 
select warehouse.location 
into wLocation 
from Customer c, Warehouse w 
where cName= 'Finch' 
and warehouse.address='  '; 
return (Location); 
end; 
+1

'% type' 전에 공백을 두는 것은 합법적입니다. –