This is the procedure section of an anonymous block from which it takes the parameter pID, parcel_id. My problem is the select statement is meant to find and display all parcels that touch the query parcel and it works perfectly fine in a normal SQL query when I put in,
select target.district_id, target.parcel_id ,query.parcel_id, sdo_geom.relate(target.geom, 'determine', query.geom, 0.05)Relationship
from Parking target, Parking query
where query.parcel_id = 68
and target.district_id = 1
and sdo_relate(target.geom, query.geom, 'mask=TOUCH') = 'TRUE';
That example returns five rows with 5 different parcels that touch the parcel 68. However, when I do it in the procedure I either get the 'TOO Many Rows Error' or if I try to add 'And Rownum <2' it works okay but doesn't show all the relationships, i.e. it runs through and displays just one relationship for each parcel. Is there anything I could do to improve this? I've been reading other posts on the site and there are references to reference cursors but I don't know how these apply here. Many thanks.
procedure Payx (pID number )is
varDistrict Parking.District_id%type;
vID Parking.parcel_id%type;
vQED Parking.parcel_id%type;
varRel varchar2(20);
begin
select target.district_id, target.parcel_id,query.parcel_id, sdo_geom.relate(target.geom, 'determine', query.geom, 0.05)Relationship
into varDistrict
vID,
vQED,
varRel
from Parking target, Parking query
where query.parcel_id = pID
and sdo_relate(target.geom, query.geom, 'mask=TOUCH') = 'TRUE'
and rownum <2;
--- dbms_output.put_line('')
end Payx;