Hi guys
OS - Solaris 8
DB - 9.2.0.7
Can anyone tell me how I can return multiple rows from a call to a procedure WITHOUT using a REF CURSOR? The reason being is the application server adapter (WebSphere) that we are using can't handle the data unless the datatypes are explicitly defined.
I'll show you an example of what i'm trying to do. The query will return two rows:
Code:
SQL> SELECT r.reviewer_name, r.review_text
2 FROM books b, reviewer r
3 WHERE b.book_id = r.book_id
4 AND author='WAITE';
REVIEWER_NAME
-------------------------
REVIEW_TEXT
--------------------------------------------------------
Mrs Woman
Its Brilliant.
Mr Man
Its really Brilliant.
This is the stored procedure that has explicit OUT parameters, rather than a REF CURSOR:
Code:
CREATE OR REPLACE PROCEDURE author_reviews ( auth IN books.author%TYPE,
rev_name OUT reviewer.reviewer_name%TYPE,
rev_text OUT reviewer.review_text%TYPE )
IS
CURSOR cur_revs IS
SELECT r.reviewer_name, r.review_text
FROM books b, reviewer r
WHERE b.book_id = r.book_id
AND author='WAITE';
BEGIN
OPEN cur_revs;
LOOP
FETCH cur_revs INTO rev_name, rev_text;
EXIT WHEN cur_revs%NOTFOUND;
END LOOP;
CLOSE CUR_REVS;
END;
/
And this is the call to the procedure:
Code:
declare
auth books.author%TYPE;
rev_name reviewer.reviewer_name%TYPE;
rev_text reviewer.review_text%TYPE;
begin
author_reviews('WAITE', rev_name, rev_text);
dbms_output.put_line('Reviews for '|| auth || ' ... reviewer ' || rev_name || ' said: '||rev_text);
end;
/
I need that call to the stored procedure to return all rows that match the query, but it is only returning one (presumably because of the scalar types I am declaring).
How would I re-write that stored procedure to return all rows?