Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Select function that returns multiple columns.

418404Apr 2 2004 — edited Apr 6 2004
Currently I have a function that will return 1 column and I can use that in a select statement. What I need is to return multiple columns from a table. In the function I have I return the street address from a table that holds information about dealers, I need to be able to also return the columns that contain the city, state, and zip code so it can be used in an sql select statement. How would I do this?

My function:

FUNCTION GET_ADDRESS(dealer_id IN number)
RETURN tbl_dealer_info.c_street%TYPE AS
v_rc tbl_dealer_info.c_street%TYPE;

CURSOR get_dealer_cur IS
SELECT c_street
FROM tbl_dealer_info
WHERE n_dealer_id = dealer_id;
BEGIN
v_rc := NULL;

OPEN get_dealer_cur;
FETCH get_dealer_cur INTO v_rc;

IF get_dealer_cur%NOTFOUND THEN
NULL;
END IF;

CLOSE get_dealer_cur;

RETURN v_rc;

EXCEPTION
WHEN OTHERS THEN
RETURN NULL;

END GET_ADDRESS;

My select statement:

select GET_ADDRESS(1205) Street, DI.n_inactive_flag, DI.n_onhold_flag
from tbl_dealer_info DI
where DI.n_dealer_id = 1205;

I would like to be able to select the street, city, state, and zip all in this select statement from the GET_ADDRESS function.

Thanks,
Lori Neirynck
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 4 2004
Added on Apr 2 2004
7 comments
6,094 views