Can anyone help?
Ive created the below stored procedure to allow an input parameter of post code to be entered to display properties which have this post code. The procedure creates fine but because i have two properties with the post code 'S1 4SG', the execution of the procedure fails, it gives the error:
ERROR at line 1:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "CBRAID.PROC_PR OPSEARCH", line 19
ORA-06512: at line 1
Im sure procedures can return more than one value, so does anyone know why its doesnt work or what i can do to make it work?
Below is the procedure and also how I execute and view it in the notepad file attached.
[code=oracle]
CREATE OR REPLACE PROCEDURE proc_PropSearch
(v_postcode IN Property.PostCo de%TYPE,
v_propertyid OUT Property.Proper tyID%TYPE,
v_propertytypei d OUT Property.Proper tyTypeID%TYPE,
v_houseflatnum OUT Property.HouseF latNumber%TYPE,
v_street OUT Property.Street %TYPE,
v_city OUT Property.City%T YPE,
v_county OUT Property.County %TYPE,
v_furnished OUT Property.Furnis hed%TYPE,
v_noofbedrooms OUT Property.NoOfBe drooms%TYPE,
v_noofensuites OUT Property.NoOfEn Suites%TYPE,
v_noofbathrooms OUT Property.NoOfBa throoms%TYPE,
v_receptionroom s OUT Property.NoOfRe ceptionRooms%TY PE,
v_propertydesc OUT Property.Proper tyDesc%TYPE,
v_available OUT Property.Availa ble%TYPE)
IS
BEGIN
SELECT PropertyID, PropertyTypeID, HouseFlatNumber , Street, City, County, Furnished, NoOfBedrooms, NoOfEnSuites, NoOfBathrooms, NoOfReceptionRo oms, PropertyDesc, Available
INTO v_propertyid, v_propertytypei d, v_houseflatnum, v_street, v_city, v_county, v_furnished, v_noofbedrooms, v_noofensuites, v_noofbathrooms , v_receptionroom s, v_propertydesc, v_available
FROM Property
WHERE PostCode = v_postcode;
END proc_PropSearch ;[/code]
/
VARIABLE g_propertyid NUMBER
VARIABLE g_propertytypei d NUMBER
VARIABLE g_houseflatnum CHAR(4)
VARIABLE g_street VARCHAR2(30)
VARIABLE g_city VARCHAR2(30)
VARIABLE g_county VARCHAR2(30)
VARIABLE g_furnished CHAR(3)
VARIABLE g_noofbedrooms NUMBER
VARIABLE g_noofensuites NUMBER
VARIABLE g_noofbathrooms NUMBER
VARIABLE g_receptionroom s NUMBER
VARIABLE g_propertydesc VARCHAR2(50)
VARIABLE g_available CHAR(3)
EXECUTE proc_PropSearch ('S1 4SG', :g_propertyid, :g_propertytype id, :g_houseflatnum , :g_street, :g_city, :g_county, :g_furnished, :g_noofbedrooms , :g_noofensuites , :g_noofbathroom s, :g_receptionroo ms, :g_propertydesc , :g_available);
PRINT g_propertyid g_propertytypei d g_houseflatnum g_street g_city g_county g_furnished g_noofbedrooms g_noofensuites g_noofbathrooms g_receptionroom s g_propertydesc g_available
This is created in PL/SQL.
Thank you for help
Ive created the below stored procedure to allow an input parameter of post code to be entered to display properties which have this post code. The procedure creates fine but because i have two properties with the post code 'S1 4SG', the execution of the procedure fails, it gives the error:
ERROR at line 1:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "CBRAID.PROC_PR OPSEARCH", line 19
ORA-06512: at line 1
Im sure procedures can return more than one value, so does anyone know why its doesnt work or what i can do to make it work?
Below is the procedure and also how I execute and view it in the notepad file attached.
[code=oracle]
CREATE OR REPLACE PROCEDURE proc_PropSearch
(v_postcode IN Property.PostCo de%TYPE,
v_propertyid OUT Property.Proper tyID%TYPE,
v_propertytypei d OUT Property.Proper tyTypeID%TYPE,
v_houseflatnum OUT Property.HouseF latNumber%TYPE,
v_street OUT Property.Street %TYPE,
v_city OUT Property.City%T YPE,
v_county OUT Property.County %TYPE,
v_furnished OUT Property.Furnis hed%TYPE,
v_noofbedrooms OUT Property.NoOfBe drooms%TYPE,
v_noofensuites OUT Property.NoOfEn Suites%TYPE,
v_noofbathrooms OUT Property.NoOfBa throoms%TYPE,
v_receptionroom s OUT Property.NoOfRe ceptionRooms%TY PE,
v_propertydesc OUT Property.Proper tyDesc%TYPE,
v_available OUT Property.Availa ble%TYPE)
IS
BEGIN
SELECT PropertyID, PropertyTypeID, HouseFlatNumber , Street, City, County, Furnished, NoOfBedrooms, NoOfEnSuites, NoOfBathrooms, NoOfReceptionRo oms, PropertyDesc, Available
INTO v_propertyid, v_propertytypei d, v_houseflatnum, v_street, v_city, v_county, v_furnished, v_noofbedrooms, v_noofensuites, v_noofbathrooms , v_receptionroom s, v_propertydesc, v_available
FROM Property
WHERE PostCode = v_postcode;
END proc_PropSearch ;[/code]
/
VARIABLE g_propertyid NUMBER
VARIABLE g_propertytypei d NUMBER
VARIABLE g_houseflatnum CHAR(4)
VARIABLE g_street VARCHAR2(30)
VARIABLE g_city VARCHAR2(30)
VARIABLE g_county VARCHAR2(30)
VARIABLE g_furnished CHAR(3)
VARIABLE g_noofbedrooms NUMBER
VARIABLE g_noofensuites NUMBER
VARIABLE g_noofbathrooms NUMBER
VARIABLE g_receptionroom s NUMBER
VARIABLE g_propertydesc VARCHAR2(50)
VARIABLE g_available CHAR(3)
EXECUTE proc_PropSearch ('S1 4SG', :g_propertyid, :g_propertytype id, :g_houseflatnum , :g_street, :g_city, :g_county, :g_furnished, :g_noofbedrooms , :g_noofensuites , :g_noofbathroom s, :g_receptionroo ms, :g_propertydesc , :g_available);
PRINT g_propertyid g_propertytypei d g_houseflatnum g_street g_city g_county g_furnished g_noofbedrooms g_noofensuites g_noofbathrooms g_receptionroom s g_propertydesc g_available
This is created in PL/SQL.
Thank you for help
Comment