How to select the row table data in pl/sql

Vaandu picture Vaandu · Apr 10, 2012 · Viewed 8.5k times · Source

Please help.

I tried this, I don't know how to proceed. I need to give a select into statement for this.

TYPE ADDR_DATA IS TABLE OF ADDRESS%ROWTYPE
INDEX BY BINARY_INTEGER;

Select is, (only one record will come), and how can I use it further?

SELECT 
    * INTO ADDR_DATA
FROM 
    ADDRESS 
WHERE           
    ADDR_DATA.PERSON_ID = 83;

Answer

A.B.Cade picture A.B.Cade · Apr 10, 2012

It looks as if you're trying to bulk collect the data, which means you need to do;

DECLARE
    v_address_data ADDR_DATA;
BEGIN
SELECT 
    * BULK COLLECT INTO v_address_data
FROM 
    ADDRESS 
WHERE           
    ADDR_DATA.PERSON_ID = 83;
END;

On the other hand you're looking for (I think) only one row - id=83
which means you want something like:

DECLARE
    v_addrss ADDRESS%ROWTYPE;
BEGIN
    SELECT 
        * INTO v_addrss 
    FROM 
        ADDRESS 
    WHERE           
        ADDR_DATA.PERSON_ID = 83;
END;