QUESTION POSED ON: 13 July 2007
Mr. Williams, I have the following Oracle procedure that returns one or more
rows depending upon the PO ID input into the SQL statement.
When there is greater than one row returned I get the ORA-01422 error. How do I
recode this procedure to allow for one to many returned rows of data?
The PO ID (input) will be passed into the proc by another program. I
have hardcoded the PO ID ('0700185') for testing pursposes. The proc is
supposed to return all vouchers associated with this PO. There may be one
voucher, there may be five vouchers.
Please be advised I am not a DBA, I am a pure novice at Oracle procedures,
but willing to learn. Thank you for any assistance you may provide.
CREATE OR REPLACE PROCEDURE TESTPNET(PO OUT VARCHAR, BATCH OUT VARCHAR2,
VOUCHER OUT VARCHAR2, INVOICE OUT VARCHAR2) AS BEGIN SELECT
PO_ID,GRP_AP_ID, VOUCHER_ID, INVOICE_ID INTO PO, BATCH, VOUCHER, INVOICE
FROM PS_VOUCHER WHERE PO_ID = '0700185'; DBMS_OUTPUT.PUT_LINE(PO);
DBMS_OUTPUT.PUT_LINE(BATCH); DBMS_OUTPUT.PUT_LINE(VOUCHER);
DBMS_OUTPUT.PUT_LINE(INVOICE); END TESTPNET;
|