我已经在论坛上看了一下,但目前还没有回答这个问题。基本上我正在尝试在我的过程中创建一个视图,因为它比一个似乎没有工作的复杂的select语句更容易,因为它返回'ORA-01422精确提取返回超过请求的行数'。我已经把声明在底部供参考
然而,视图选项似乎没有工作它返回另一个错误'遇到符号“CREATE”时期望以下之一:'。有什么我做错了吗?
感谢您一看。
procedure proRekt (par_id number) is
vardec farm.parcel.description%type;
vland farm.landuse.landuse_id%type;
v_luse farm.landuse.landuse%type;
varpl farm.parcel.parcel_id%type;
begin
create or replace view Door as
select a.parcel_id,a.description,b.landuse_id,c.landuse
from
farm.parcel a,
farm.parcel_landuse b,
farm.landuse c
where a.parcel_id = b.parcel_id
and b.landuse_id = c.landuse_id;
select parcel_id,description,landuse
into varpl,
vardec,
vland
from door
where parcel_id = parID;
****错误的选择陈述
select a.parcel_id,c.description,a.landuse_id,b.landuse
into varpl,
vardec,
vland,
v_luse
from farm.parcel_landuse a,
farm.landuse b,
farm.parcel c
where c.parcel_id = parID
and a.landuse_id = b.landuse_id
and a.parcel_id = c.parcel_id;
答案 0 :(得分:1)
在SQL范围中创建视图:
create or replace view Door as
select a.parcel_id,
a.description,
b.landuse_id,
c.landuse
from tithedb.parcel a
INNER JOIN tithedb.parcel_landuse b
ON ( a.parcel_id = b.parcel_id )
INNER JOIN tithedb.landuse c
ON ( b.landuse_id = c.landuse_id );
在过程的PL / SQL范围内使用它:
procedure proexempt (parID number)
is
vardescription tithedb.parcel.description%type;
varland tithedb.landuse.landuse_id%type;
varlanduse tithedb.landuse.landuse%type;
varparcel tithedb.parcel.parcel_id%type;
begin
select parcel_id,
description,
landuse
into varparcel,
vardescription,
varlanduse
from door
where parcel_id = parID;
-- ... more stuff
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL; -- Handle error here.
WHEN TOO_MANY_ROWS THEN
NULL; -- Handle error here (or use "AND ROWNUM = 1" in your query).
END proexempt;
/