Skip to Main Content

How to add records or how to maintain list in stored Procedure

Sardar NaleSep 25 2013 — edited Sep 25 2013

Hi,

I am facing an issue in the addition of record in the type

create or replace

TYPE               "PROD_SEARCH_COUNT_TBL"                                          AS TABLE OF PROD_SEARCH_COUNT_OBJ;

create or replace

TYPE               "PROD_SEARCH_COUNT_OBJ"                                          AS OBJECT

( /* TODO enter attribute and method declarations here */

    V_Name Varchar2(500 Byte),

    v_Value Varchar2(500 Byte),

    v_count Number

)

I want to add records to the type I tried following way

prod_wcf_rec PROD_SEARCH_COUNT_TBL;

  SELECT PROD_SEARCH_COUNT_OBJ('Name1','Value1',1) BULK COLLECT INTO prod_wcf_rec FROM DUAL;

    SELECT PROD_SEARCH_COUNT_OBJ('Name2','Value2',2) BULK COLLECT INTO prod_wcf_rec FROM DUAL;

    SELECT PROD_SEARCH_COUNT_OBJ('Name3','Value3',3) BULK COLLECT INTO prod_wcf_rec FROM DUAL;

    SELECT PROD_SEARCH_COUNT_OBJ('Name4','Value4',4) BULK COLLECT INTO PROD_WCF_REC FROM DUAL;

DBMS_OUTPUT.PUT_LINE ('-----------------------------Looping----------------------------');
FOR i in 1 .. prod_wcf_rec.COUNT
LOOP         
    DBMS_OUTPUT.PUT_LINE (prod_wcf_rec(i).V_Name||' - '||prod_wcf_rec(i).v_Value||' - '||prod_wcf_rec(i).v_count);     

   END LOOP;

   DBMS_OUTPUT.PUT_LINE ('-----------------------------Looping----------------------------');

In printing I am getting last records only .So is there any way to add records to PROD_SEARCH_COUNT_TBL

How to add records or how to maintain list in stored Procedure

Comments
Post Details
Added on Sep 25 2013
5 comments
157 views