VARRAY padding in procedure

Hi all,
Im a little new to this so please bear with me..
I have created a type of VARRAY:
CREATE OR REPLACE TYPE rows_of as VARRAY(10) OF CHAR;
And a procedure that takes two of the types. What I want the procedure to do is pad out the lenth of sencond type being passed in with '-' charctor. Below is the procedure I have written but for some reason it keeps throwing me the error:
ERROR at line 1:
ORA-06533: Subscript beyond count
ORA-06512: at "PADD", line 14
ORA-06512: at line 6
CREATE OR REPLACE PROCEDURE padd(row1 rows_of, row2 rows_of)
IS
count_entry NUMBER:=row1.LAST;
count_test NUMBER:=row2.LAST;
dummby_row rows_of:=rows_of();
BEGIN
dummby_row:=row2;
IF (count_entry > count_test) THEN
FOR i IN row2.LAST + 1 ..row1.LAST
LOOP
dummby_row(i):='-' ;
END LOOP;
END IF;
END;
show error
This is the execution block I am sending:
DECLARE
row1 rows_of:=rows_of('3','7','2','3','-','-');
row2 rows_of:=rows_of('-','-','3');
answer rows_of;
BEGIN
padd(row1, row2);
END;
Could anyone help me out to where I am wrong? It has something to do with dummby_row(i):='-' ; but Ive tried different assignments and cannot get it to work.
Thanks in advance!
Stef

I've just seen this one pass elsewhere ;)
You assign row2 to dummby_row. Now dummby_row has no more records than row2, so your loop immediately goes wrong with the mentioned error. As a first line in the loop, add a
dummby_row.extend();MHE

Similar Messages

  • Passing table of varray to a procedure

    Hi,
    I have a procedure which takes the following parameters:
    create or replace
    PROCEDURE VECTORSUMMARYSTATISTICS
    chartOption IN CHARTOPTION,
    userChoicedate IN C_TAB,
    AllCases IN boolean,
    strVector_id VARCHAR2,
    strEntityName VARCHAR2,
    CollectionName VARCHAR2
    ) AS
    C_TAB is a type created on the database:
    create or replace
    TYPE C_TAB AS TABLE OF C_REC;
    And C_REC:
    create or replace
    TYPE C_REC AS OBJECT
    time_value TIMESTAMP
    In the body of the procedure I am using the table "userChoicedate" in the following way:
    for idx in userChoicedate.first..userChoicedate.last
    loop
    tuserdate_rec:=userChoicedate(idx); //table passed from the parameter
    tuserdate.extend(1);
    tuserdate(idx):=tuserdate_rec;
    end loop;
    where tuserdate_rec is declared in the following way:
    --record for holding a single user date
    tuserdate_rec C_REC;
    Before executing this procedure from pl/sql I am filling some test date from another pl/sql page:
    percRec2 C_REC;
    result_tab C_TAB;
    result_tab:=C_TAB();
    result_tab.extend(10);
    percRec2:=C_REC(TO_TIMESTAMP('01-01-2004 12:00:00.000', 'DD-MM-YYYY HH:MI:SS.FF3') );
    result_tab(1):=percRec2;
    percRec2:=C_REC(TO_TIMESTAMP('01-04-2004 12:00:00.000', 'DD-MM-YYYY HH:MI:SS.FF3') );
    result_tab(2):=percRec2;
    percRec2:=C_REC(TO_TIMESTAMP('01-07-2004 12:00:00.000', 'DD-MM-YYYY HH:MI:SS.FF3'));
    result_tab(3):=percRec2;
    percRec2:=C_REC(TO_TIMESTAMP('01-10-2004 12:00:00.000', 'DD-MM-YYYY HH:MI:SS.FF3'));
    result_tab(4):=percRec2;
    So when calling the procedure:
    VECTORSUMMARYSTATISTICS(ch,result_tab,FALSE,'WBHP','PRD3','CaseCollection1');
    I am getting the following error message:
    Error report:
    ORA-06531: Reference to uninitialized collection
    ORA-06512: at "SIMSERVER.VECTORSUMMARYSTATISTICS", line 184
    ORA-06512: at line 54
    06531. 00000 - "Reference to uninitialized collection"
    *Cause:    An element or member function of a nested table or varray
    was referenced (where an initialized collection is needed)
    without the collection having been initialized.
    *Action:   Initialize the collection with an appropriate constructor
    or whole-object assignment.
    So here at this line in bold the problem is:
    For idx in userChoicedate.first..userChoicedate.last
    loop
    tuserdate_rec:=userChoicedate(idx);
    tuserdate.extend(1);
    tuserdate(idx):=tuserdate_rec;
    end loop;
    Any help
    Thanks
    Message was edited by:
    user646975

    Hi,
    Are u sure cause always the procedure is not compiling
    This time I got the following problem:
    Error(182,11): PLS-00103: Encountered the symbol "(" when expecting one of the following: in The symbol "in" was substituted for "(" to continue.
    Error(320,71): PLS-00103: Encountered the symbol "GROUP" when expecting one of the following: , from into bulk

  • PASSING A VARRAY as parameter in a procedure and returning the same VARRAY

    Hi,
    I am passing a varray as IN parameter to a procedure. I want to retreive the same VARRAY from the procedure.
    DECLARE
       TYPE str_array IS VARRAY (4) OF VARCHAR2 (50);
       v_array           str_array;  
       PROCEDURE process_array (
          v_str_array             str_array
       AS
       BEGIN
          FOR i IN v_str_array.FIRST .. v_str_array.LAST
          LOOP
             DBMS_OUTPUT.put_line ('Hello ' || v_str_array (i));
          END LOOP;
       END;
    BEGIN
       v_array    := str_array ('John', 'Paul', 'Ringo', 'George');
       process_array (v_array);
       -- can also pass unbound Str_Array
       --process_array (str_array ('John', 'Paul', 'Ringo', 'George'));
    --   DBMS_OUTPUT.put_line ('Hello ' || v_str_out_array (i));
    END;I want to change this procedure so that i will retreive the same as VARRAY out from the procedure.
    Can anyone help me on the same

       PROCEDURE process_array (
          v_str_array             IN OUT str_array
       )If your varray is large then you can try:
       PROCEDURE process_array (
          v_str_array             IN OUT NOCOPY str_array
       )but you should learn about possible side-effects if there is an error while executing the procedure. In short words: if you don't use NOCOPY and an error occurs during execution of process_array procedure then your varray is not changed - all chages to the value of your varray are 'rolled back'. If you use NOCOPY then it depends...

  • VARRAYS - how to use in sub procedures and how to empty them?

    Hi!
    I made a procedure where i use three diffrent varrays. I got it working only after
    putting all code in one big MAIN-block. Looks nasty.
    If i try to use sub-procedures i allways got ORA-06531-message.
    = "Reference to uninitialized collection"
    How can i use varrays in sub-procedures? Is there some trick in delcare or in procedure call?
    I try to use IN OUT parameters, but i didn't get it working. Run out of time in trial and error, of cource...
    I seemed to me that varrays aren't same way usable allover in code as all other variables i have declared.
    Is it so?
    Now the MAIN-block is long as a year... I'm used to code short MAIN-block with many sub-procedures calls.
    (In same procedure, not different procedures in db).
    Another problem is how to empty a varray in effective way?
    I tried my_varray.DELELTE and my_varray.TRIM but they won't do the thing. These remove/trim the elements but i just need to
    empty varray before fetching a new line from db. If I my_varray := NULL; then that same ORA-06531 when next read/write in varray.
    Now i just use FOR i IN 1..120 LOOP
    my_varray(i) := NULL;
    END LOOP;
    but there must be better way, hope so.
    Cheers,
    SL

    You were rigth "3360" - i had three varrays too many. Just to the grabage bin and some recoding.
    The link you posted show me the way: Associative Arrays
    - easy to declare, easy to use, works fine in sub procedures. Great - just what i need.
    Thanks alot!
    I fully agree W. Robertson on this:
    "I often see questions on technical forums about arrays in PL/SQL, which type to use and what the differences are. Although the documentation has quite a lot to say on the subject, I feel it tries to introduce too many concepts at once and ends up being confusing, especially when it comes to choosing between VARRAYs and Nested Table collections, where most of the "which to use" advice is about collection columns of database tables (which you probably don't need), and not about PL/SQL at all."
    - sl -

  • Bug:4705928 PLSQL: Memory leak using small varrays

    We have Oracle version 10.2.0.1.0
    We have a problem with a procedure.
    In our scenario we make use of VARRAY in the procedure to pass some filter parameters to a select distinct querying a view made on three tables.
    Unfotunately not always execution it is successful.
    Sometimes it returns wrong value (0 for the count parameter), sometimes (rarely) the server stops working.
    We suspect that this is caused by a bug fixed in versione 10.2.0.3.0
    Bug:4705928 PLSQL: Memory leak using small varrays when trimming the whole collection and inserting into it in a loop
    We suspect this becasue we made two procedure the first (spProductCount) uses a function (fnProductFilter) to calculate the values of a varray and passes them into the select,
    while in the second procedure (spProductCount2) parameters are passed directly into the statement without varray
    and there are failures only in the first procedure.
    On the other hand on another server 10.2.0.1.0 we never have this problem.
    The instance manifesting the bug runs under shared mode, while the other is under dedicated mode.
    Turning the first one to dedicated mode makes the bugs disapear.
    Unfortunately this is not a solution.
    In the sample there are the three table with all constraints, the view, tha varray custom type, the function and the two procedures.
    Is there someone that may examine our sample and tell us if the pl/sql code corresponds to the bug desciption.
    We also want to know if it's possibile that the same server running under different mode (SHARED/DEDICATED) doesn't behave the same way.
    The tables:
    --Products
    CREATE TABLE "Products" (
         "Image" BLOB
         , "CatalogId" RAW(16)
         , "ProductId" RAW(16)
         , "MnemonicId" NVARCHAR2(50) DEFAULT ''
         , "ProductParentId" RAW(16)
    ALTER TABLE "Products"
         ADD CONSTRAINT "NN_Products_M04" CHECK ("CatalogId" IS NOT NULL)
    ALTER TABLE "Products"
         ADD CONSTRAINT "NN_Products_M05" CHECK ("ProductId" IS NOT NULL)
    ALTER TABLE "Products"
    ADD CONSTRAINT "PK_Products"
    PRIMARY KEY ("ProductId")
    CREATE INDEX "IX_Products"
    ON "Products" ("CatalogId", "MnemonicId")
    CREATE UNIQUE INDEX "UK_Products"
    ON "Products" (DECODE("MnemonicId", NULL, NULL, RAWTOHEX("CatalogId") || "MnemonicId"))
    --Languages
    CREATE TABLE "Languages" (
         "Description" NVARCHAR2(250)
         , "IsStandard" NUMBER(1)
         , "LanguageId" RAW(16)
         , "MnemonicId" NVARCHAR2(12)
    ALTER TABLE "Languages"
         ADD CONSTRAINT "NN_Languages_M01" CHECK ("LanguageId" IS NOT NULL)
    ALTER TABLE "Languages"
         ADD CONSTRAINT "NN_Languages_M05" CHECK ("MnemonicId" IS NOT NULL)
    ALTER TABLE "Languages"
    ADD CONSTRAINT "PK_Languages"
    PRIMARY KEY ("LanguageId")
    ALTER TABLE "Languages"
    ADD CONSTRAINT "UK_Languages"
    UNIQUE ("MnemonicId")
    --ProductDesc
    CREATE TABLE "ProductDesc" (
         "Comment" NCLOB
         , "PlainComment" NCLOB
         , "Description" NVARCHAR2(250)
         , "DescriptionText" NCLOB
         , "PlainDescriptionText" NCLOB
         , "LanguageId" NVARCHAR2(12)
         , "ProductId" RAW(16)
    ALTER TABLE "ProductDesc"
         ADD CONSTRAINT "NN_ProductDescM01" CHECK ("LanguageId" IS NOT NULL)
    ALTER TABLE "ProductDesc"
         ADD CONSTRAINT "NN_ProductDescM02" CHECK ("ProductId" IS NOT NULL)
    ALTER TABLE "ProductDesc"
    ADD CONSTRAINT "PK_ProductDesc"
    PRIMARY KEY ("ProductId", "LanguageId")
    ALTER TABLE "ProductDesc"
    ADD CONSTRAINT "FK_ProductDesc1"
    FOREIGN KEY("ProductId") REFERENCES "Products" ("ProductId")
    ALTER TABLE "ProductDesc"
    ADD CONSTRAINT "FK_ProductDesc2"
    FOREIGN KEY("LanguageId") REFERENCES "Languages" ("MnemonicId")
    /The view:
    --ProductView
    CREATE OR REPLACE VIEW "vwProducts"
    AS
         SELECT
               "Products"."CatalogId"
              , "ProductDesc"."Comment"
              , "ProductDesc"."PlainComment"
              , "ProductDesc"."Description"
              , "ProductDesc"."DescriptionText"
              , "ProductDesc"."PlainDescriptionText"
              , "Products"."Image"
              , "Languages"."MnemonicId" "LanguageId"
              , "Products"."MnemonicId"
              , "Products"."ProductId"
              , "Products"."ProductParentId"
              , TRIM(NVL("ProductDesc"."Description" || ' ', '') || NVL("ParentDescriptions"."Description", '')) "FullDescription"
         FROM "Products"
         CROSS JOIN "Languages"
         LEFT OUTER JOIN "ProductDesc"
         ON "Products"."ProductId" = "ProductDesc"."ProductId"
         AND "ProductDesc"."LanguageId" = "Languages"."MnemonicId"
         LEFT OUTER JOIN "ProductDesc" "ParentDescriptions"
         ON "Products"."ProductParentId" = "ParentDescriptions"."ProductId"
         AND ("ParentDescriptions"."LanguageId" = "Languages"."MnemonicId")
    /The varray:
    --CustomType VARRAY
    CREATE OR REPLACE TYPE Varray_Params IS VARRAY(100) OF NVARCHAR2(1000);
    /The function:
    --FilterFunction
    CREATE OR REPLACE FUNCTION "fnProductFilter" (
         parCatalogId "Products"."CatalogId"%TYPE,
         parLanguageId                    NVARCHAR2 := N'it-IT',
         parFilterValues                    OUT Varray_Params
    RETURN INTEGER
    AS
         varSqlCondition                    VARCHAR2(32000);
         varSqlConditionValues          NVARCHAR2(32000);
         varSql                              NVARCHAR2(32000);
         varDbmsCursor                    INTEGER;
         varDbmsResult                    INTEGER;
         varSeparator                    VARCHAR2(2);
         varFilterValue                    NVARCHAR2(1000);
         varCount                         INTEGER;
    BEGIN
         varSqlCondition := '(T_Product."CatalogId" = HEXTORAW(:parentId)) AND (T_Product."LanguageId" = :languageId )';
         varSqlConditionValues := CHR(39) || TO_CHAR(parCatalogId) || CHR(39) || N', ' || CHR(39 USING NCHAR_CS) || parLanguageId || CHR(39 USING NCHAR_CS);
         parFilterValues := Varray_Params();
         varSql := N'SELECT FilterValues.column_value FilterValue FROM TABLE(Varray_Params(' || varSqlConditionValues || N')) FilterValues';
         BEGIN
              varDbmsCursor := dbms_sql.open_cursor;
              dbms_sql.parse(varDbmsCursor, varSql, dbms_sql.native);
              dbms_sql.define_column(varDbmsCursor, 1, varFilterValue, 1000);
              varDbmsResult := dbms_sql.execute(varDbmsCursor);
              varCount := 0;
              LOOP
                   IF (dbms_sql.fetch_rows(varDbmsCursor) > 0) THEN
                        varCount := varCount + 1;
                        dbms_sql.column_value(varDbmsCursor, 1, varFilterValue);
                        parFilterValues.extend(1);
                        parFilterValues(varCount) := varFilterValue;
                   ELSE
                        -- No more rows to copy
                        EXIT;
                   END IF;
              END LOOP;
              dbms_sql.close_cursor(varDbmsCursor);
         EXCEPTION WHEN OTHERS THEN
              dbms_sql.close_cursor(varDbmsCursor);
              RETURN 0;
         END;
         FOR i in parFilterValues.first .. parFilterValues.last LOOP
              varSeparator := ', ';
         END LOOP;
         RETURN 1;
    END;
    /The procedures:
    --Procedure presenting anomaly\bug
    CREATE OR REPLACE PROCEDURE "spProductCount" (
         parCatalogId "Products"."CatalogId"%TYPE,
         parLanguageId NVARCHAR2 := N'it-IT',
         parRecords OUT NUMBER
    AS
         varFilterValues Varray_Params;
         varResult INTEGER;
         varSqlTotal VARCHAR2(32000);
    BEGIN
         parRecords := 0;
         varResult := "fnProductFilter"(parCatalogId, parLanguageId, varFilterValues);
         varSqlTotal := 'BEGIN
         SELECT count(DISTINCT T_Product."ProductId") INTO :parCount FROM "vwProducts" T_Product
              WHERE ((T_Product."CatalogId" = HEXTORAW(:parentId)) AND (T_Product."LanguageId" = :languageId ));
    END;';
         EXECUTE IMMEDIATE varSqlTotal USING OUT parRecords, varFilterValues(1), varFilterValues(2);
    END;
    --Procedure NOT presenting anomaly\bug
    CREATE OR REPLACE PROCEDURE "spProductCount2" (
         parCatalogId "Products"."CatalogId"%TYPE,
         parLanguageId NVARCHAR2 := N'it-IT',
         parRecords OUT NUMBER
    AS
         varFilterValues Varray_Params;
         varResult INTEGER;
         varSqlTotal VARCHAR2(32000);
    BEGIN
         parRecords := 0;
         varSqlTotal := 'BEGIN
         SELECT count(DISTINCT T_Product."ProductId") INTO :parCount FROM "vwProducts" T_Product
              WHERE ((T_Product."CatalogId" = HEXTORAW(:parentId)) AND (T_Product."LanguageId" = :languageId ));
    END;';
         EXECUTE IMMEDIATE varSqlTotal USING OUT parRecords, parCatalogId, parLanguageId;
    END;Edited by: 835125 on 2011-2-9 1:31

    835125 wrote:
    Using VARRAY was the only way I found to transform comma seprated text values (e.g. "'abc', 'def', '123'") in a collection of strings.A varray is just a functionally crippled version of a nested table collection type, with a defined limit you probably don't need. (Why 100 specifically?) Instead of
    CREATE OR REPLACE TYPE varray_params AS VARRAY(100) OF NVARCHAR2(1000);try
    CREATE OR REPLACE TYPE array_params AS TABLE OF NVARCHAR2(1000);I don't know whether that will solve the problem but at least it'll be a slightly more useful type.
    What makes you think it's a memory leak specifically? Do you observe session PGA memory use going up more than it should?
    btw good luck with all those quoted column names. I wouldn't like to have to work with those, although they do make the forum more colourful.
    Edited by: William Robertson on Feb 11, 2011 7:54 AM

  • Getting the name of the varray

    Getting the original name of the Varray:
    9.2.0.6
    I have a simple procedure which does work but I would like to tighten it up.
    procedure printVarray(u IN numUsed, varrayName IN VARCHAR2 DEFAULT NULL) is
    begin
    IF varrayName IS NOT NULL THEN
         dbms_output.put_line('Working on Varray ' || varrayName);
         for i in u.first..u.last loop
    dbms_output.put_line('u[' || i || '] = ' || u(i).num || ' '
    || u(i).cnt);
    end loop;
              dbms_output.put_line(' ');
    END IF;          
    end printVarray;
    assuming u1 , u2, u3 & u4 are initialized and has values then
    I can from a block do
    begin
    printVarray(u1,'u1');
    printVarray(u2,'u2');
    printVarray(u3,'u3');
    printVarray(u4,'u4');
    end;
    and get the output I would expect:
    ... lines not show above
    Working on Varray u3
    u[1] = 1 2
    u[2] = 2 3
    u[3] = 3 4
    u[4] = 4 3
    Working on Varray u4
    u[1] = 1 1
    u[2] = 2 2
    u[3] = 3 3
    u[4] = 4 3
    My question is how can I do away with passing the name of the original varray
    to the procedure printVarray and still have it print the name of the original
    varray?
    Thanks

    Not possible in PL/SQL dynamically if you're thinking alone those lines. You will need to pass a separate (manual) varchar2 parameter containing the name of the variable - as your printVarray() proc is currently doing.
    You can simply change the DBMS_OUTPUT to:
    dbms_output.put_line( varrayName||'[' || i || '] = ' || u(i).num || ' '
    || u(i).cnt);

  • Display invalid pattern name while calling the procedure inside the package

    Hi ,
    I'am trying to call a package which is having procedure ,from JDBC in which one of the return type is Varray from the procedure.When i'am calling the procedure inside the package
    from java showing invalid name pattern name.Just i'am placing the code snippet for package and calling java through package.
    Package body
    create or replace package body Rewards_Summary_Package as
    PROCEDURE Rewards_Summary_Procedure
    (v_Tot_Earned_Points OUT NUMBER, v_TOT_REDEEMED OUT NUMBER, v_TOT_PTS_EXP OUT NUMBER,
    v_TOT_AVAILABLE OUT NUMBER, v_TIER_NAME OUT VARCHAR2,VA OUT t_varray,V_PR_CON_ID IN VARCHAR2) AS
    v_ACCRUALED_VAL NUMBER := 0;
    v_USED_VAL NUMBER := 0;
    /*v_TOT_ACCRUALED_VAL NUMBER := 0;
    v_TOT_USED_VAL NUMBER := 0;
    V_PR_TIER_ID VARCHAR2(30);
    V_PR_CON_ID VARCHAR2(30);
    V_EXPIRY_DT DATE;
    v_month varchar2(30);
    v_date date;
    v_next_month_date date;
    v_TIER_NAME VARCHAR2(50);
    v_TOT_AVAILABLE NUMBER := 0;
    v_EARNED NUMBER := 0;
    v_TOT_EARNED NUMBER := 0;
    v_TOT_REDEEMED NUMBER := 0;
    v_TOT_EXPIRED NUMBER := 0;
    v_EARNED_TOTAL NUMBER := 0;
    v_TOT_EXPIRED_MONTH NUMBER := 0;
    v_TOT_PTS_EXP NUMBER := 0;
    v_TOT_RDMD_CANCELLED NUMBER :=0;
    v_TOT_EARNED_POINTS NUMBER :=0;*/
    v_FIRST_DT DATE;
    v_LAST_DT DATE;
    v_MEMBER_ID VARCHAR2(30);
    V_EXPIRED_VAL Number;
    v_TOT_PRDPTS_RDMD NUMBER := 0;
    v_TOT_PTS_RDMD NUMBER := 0;
    v_CAN_ACCRUAL_POINTS NUMBER := 0;
    BEGIN
    /*TotalRwdPoints and Tier Name*/
    SELECT TR.NAME,MEM.POINT_TYPE_A_VAL,MEM.ROW_ID INTO v_TIER_NAME,v_TOT_AVAILABLE,v_MEMBER_ID
    FROM SIEBEL.S_LOY_MEMBER MEM, SIEBEL.S_LOY_TIER TR WHERE MEM.PR_DOM_TIER_ID=TR.ROW_ID
    AND MEM.PR_CON_ID=V_PR_CON_ID;
    vTotPrdPtsRdmd
    SELECT NVL(SUM(A.VALUE),0) INTO v_TOT_PRDPTS_RDMD from SIEBEL.S_LOY_RDM_ITM A,SIEBEL.S_LOY_ATTRDEFN B
    WHERE A.MEMBER_ID = v_MEMBER_ID AND A.ATTRB_DEFN_ID = B.ROW_ID AND b.INTERNAL_NAME = 'Point 1 Value' AND A.TYPE_CD='Product'
    AND A.TXN_ID IS NOT NULL;
    vTotPtsRdmd
    SELECT NVL(SUM(A.VALUE),0) INTO v_TOT_PTS_RDMD from SIEBEL.S_LOY_RDM_ITM A,SIEBEL.S_LOY_ATTRDEFN B
    WHERE A.MEMBER_ID = v_MEMBER_ID AND A.ATTRB_DEFN_ID = B.ROW_ID AND b.INTERNAL_NAME = 'Point 1 Value' AND (A.TYPE_CD='Product' or A.TYPE_CD='Transfer')
    AND A.TXN_ID IS NOT NULL;
    vTotRewardPtExp
    SELECT NVL(SUM(A.VALUE),0) INTO v_TOT_PTS_EXP FROM SIEBEL.S_LOY_RDM_ITM A,SIEBEL.S_LOY_ATTRDEFN B
    WHERE A.MEMBER_ID = v_MEMBER_ID AND A.ATTRB_DEFN_ID = B.ROW_ID AND b.INTERNAL_NAME = 'Point 1 Value' AND A.TYPE_CD='Expired'
    AND a.TXN_ID IS NULL;
    vCanAccrualPoints
    SELECT NVL(SUM(A.ACCRUALED_VALUE),0) INTO v_CAN_ACCRUAL_POINTS from SIEBEL.S_LOY_ACRL_ITM A,SIEBEL.S_LOY_ATTRDEFN B
    WHERE A.MEMBER_ID = v_MEMBER_ID AND A.ATTRIB_DEFN_ID = B.ROW_ID AND b.INTERNAL_NAME = 'Point 1 Value' AND A.TYPE_CD='Cancellation';
    v_Tot_Earned_Points := v_TOT_AVAILABLE+v_TOT_PRDPTS_RDMD+v_TOT_PTS_EXP-v_CAN_ACCRUAL_POINTS;
    v_TOT_REDEEMED := v_TOT_PTS_RDMD-v_CAN_ACCRUAL_POINTS;
    DBMS_OUTPUT.PUT_LINE(' Total Earned: '|| v_Tot_Earned_Points || ' Total Redeemed: '|| v_TOT_REDEEMED || ' Total Expired: '|| v_TOT_PTS_EXP
    || ' Balance Points: '|| v_TOT_AVAILABLE || ' Tier Name: '|| v_TIER_NAME);
    select trunc(sysdate,'MONTH') INTO v_FIRST_DT from dual;
    va:= t_varray(Null,Null,Null,Null,Null,Null);
    FOR a in 1 .. 6 LOOP
    select trunc(last_day(v_FIRST_DT)) INTO v_LAST_DT from dual;
    SELECT SUM(AI.ACCRUALED_VALUE),SUM(AI.USED_VALUE) INTO v_ACCRUALED_VAL,v_USED_VAL from SIEBEL.S_LOY_ACRL_ITM AI,SIEBEL.S_LOY_ATTRDEFN A
    WHERE AI.MEMBER_ID = v_MEMBER_ID AND A.ROW_ID = AI.ATTRIB_DEFN_ID AND A.INTERNAL_NAME = 'Point 1 Value'
    AND trunc(AI.EXPIRATION_DT) >= v_FIRST_DT AND trunc(AI.EXPIRATION_DT) <= v_LAST_DT;
    V_EXPIRED_VAL := NVL(v_ACCRUALED_VAL-v_USED_VAL,0);
    va(a):=V_EXPIRED_VAL;
    v_FIRST_DT := add_months(v_FIRST_DT,1);
    End loop;
    END;
    end;
    Package declaration
    create or replace package Rewards_Summary_Package as
    TYPE t_varray IS VARRAY(6) OF NUMBER;
    PROCEDURE Rewards_Summary_Procedure
    (v_Tot_Earned_Points OUT NUMBER, v_TOT_REDEEMED OUT NUMBER, v_TOT_PTS_EXP OUT NUMBER,
    v_TOT_AVAILABLE OUT NUMBER, v_TIER_NAME OUT VARCHAR2,VA OUT t_varray,V_PR_CON_ID IN VARCHAR2);
    end;
    java code
    I had tried using java types and Oracle types
    conn=SiebelServiceDatasource.getConnection(SSBConstants.REWARDS_PROP_LOG_SUFIX);
    // ArrayDescriptor.TYPE_VARRAY
    ocstmt=(OracleCallableStatement)conn.prepareCall(" {call REWARDS_SUMMARY_PACKAGE.REWARDS_SUMMARY_PROCEDURE(?,?,?,?,?,?,?)}");
    //ocstmt=(OracleCallableStatement)conn.prepareCall(" call Test_Array(?,?)");
    ocstmt.registerOutParameter(1,OracleTypes.INTEGER);
    ocstmt.registerOutParameter(2,OracleTypes.INTEGER);//1-616BH
    ocstmt.registerOutParameter(3,OracleTypes.INTEGER);
    ocstmt.registerOutParameter(4,OracleTypes.INTEGER);
    ocstmt.registerOutParameter(5,OracleTypes.VARCHAR);
    ocstmt.registerOutParameter(6,OracleTypes.ARRAY,"SIEBEL.T_VARRAY");
    ocstmt.setString(7,contactSiebelRowId);
    ocstmt.execute();
    Showing the following invalid name pattern SIEBEL.T_VARRAY
    Please help
    Thanks in advance
    Kiran

    create or replace package Rewards_Summary_Package as
        TYPE t_varray IS VARRAY(6) OF NUMBER;
    end;You've declared your type inside the package. You need to declare it as a SQL type, which is not part of a PL/SQL package.

  • Regarding Varrays (Urgent)

    Dear Experts,
    Please tell me how to store emp_name in varray.
    and I need to pass that varray to another procedure.
    so please send code .

    All forum volunteers are assisting with other issues right now, your request has been logged and will be answered some time within the next six months.
    If this is an urgent request please contact your support representative or engage qualified qualified consultants.

  • Assertion failure

    Hi!,
    We are trying to get varray from stored procedure as out var.
    we have defined its type of varchar as
    create type <name> of varray(123) as varchar2(123)
    Now when my length of varray is more than 50 i get assertion failure at client side.
    I am using java2 and release 2.
    Thanks.

    Assertion Failures can be caused by corruption in the DNS objects. It
    might be related to avalon.iks-jena.de, since that is the last thing
    mentioned. You could try recreating that A record. You can also try
    exporting, removing, and imported the zone.

  • Copy values from stored procedure to a text pad

    Any Suggestions
    We have a table 'A' and wrote a select query to get the values from that table 'A'. I place this select query in Stored procedure and when I run that procedure every month the output should be sent t a text pad. Any suggestions how to write it
    thanks
    Is there any other method if we dont have the privelage to create directory?
    Edited by: user646635 on Oct 2, 2008 7:16 AM

    user646635 wrote:
    want to store the output in a text file?
    we are using oracle 9iHere's a basic example for you...
    AS SYS:
    create or replace directory TEST_DIR as 'c:\test_dir'; -- This creates an oracle directory object.  The actual operating system directory must be created manually
    grant read,write on directory test_dir to my_user;  -- Grant permission to use that directory object to the required user(s)AS my_user:
    declare
      cursor cur_emp is
        select ename, deptno
        from emp;
      v_fh UTL_FILE.FILE_TYPE;  -- This is a file handle
    begin
      v_fh := UTL_FILE.FOPEN('TEST_DIR', 'file.txt', 'w', 32767);  -- Open the file for writing and obtain a handle to it
      FOR i IN cur_emp -- process the query in a loop
      LOOP
        UTL_FILE.FPUT_LINE(v_fh, i.ename||','||to_char(i.deptno,'fm099')); -- write out lines of text to the file
      END LOOP;
      UTL_FILE.FCLOSE(v_fh); -- Close the file (also flushes any unwritten buffered data).
    end;

  • Calling a stored procedure with VARRAY as out parameter using JDBC

    Hi,
    I want to use the data type VARRAY as an out parameter in an Oracle stored procedure. I want to call the stored procedure from
    my java program using JDBC.
    I'm using Oracle 8.1.5 for Windows NT.
    Please help me.
    Thanks
    Sumanta
    null

    Originally posted by JDBC Development Team:
    It's very similar to other datatype except that it uses OracleTypes.ARRAY typecode and the value is mapped to a oracle.sql.ARRAY instance. The code looks as follows --
    cstmt.registerOutParameter (idx, OracleTypes.ARRAY, "VARRAY_TYPE_NAME_HERE");
    cstmt.execute ();
    ARRAY array = (ARRAY) cstmt.getObject (idx);
    Thanks for your reply.
    I have to use:-
    OracleCallableStatement cs1 = (OracleCallableStatement )conn.prepareCall
    ( "{call proj_array(?)}" ) ;
    for retrieving a collection as an OUT parameter.
    This gives me the errors:-
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Array getArray(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Clob getClob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Ref getRef(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    How do I get rid of these errors?
    null

  • Calling Stored Procedure(takes varray of objects as input) from jdeveloper

    How can i call Stored Procedure which takes varray of objects as input from jdeveloper
    My object is :
    TYPE Entry IS Object (
    Name VARCHAR2(1024),
    Value VARCHAR2(1024)
    & the varray is :
    TYPE EntryArr IS varray(10) OF Entry ;
    & the procedure is :
    PROCEDURE myProc( myEntryArr IN EntryArr )
    AS
    s varchar2(1024);
    BEGIN
    for i in 1.. myEntryArr .COUNT loop
    if myEntryArr(i).Name = 'Name1' then
    s := myEntryArr(i).Value
    end loop;
    end;

    hi 429071
    Maybe you can find some useful information in:
    "Oracle Database Java Developer's Guide"
    http://download-west.oracle.com/docs/cd/B14117_01/java.101/b12021.pdf
    see "6 Publishing Java Classes With Call Specs" > "Writing Object Type Call Specs"
    success
    Jan Vervecken

  • Usage of Varray in a Stored Procedure Executed through OCIStmtExecute

    Hi,
    I'm new to OCI Programming. My requirement is to pass an array to a Stored Procedure.
    In Stored Procedure this input variable is of type VARRAY.
    I'm following the approach given below.
    OCITypeByName()
    OCIObjectNew()
    OCICollAppend()
    OCIBindByPos()
    OCIBindByObject()
    OCIStmtExecute()
    I encounter an error in OCITypeByName (this function call fails)
    Can anyone provide me some sample codes
    Also pls provide information if there is a better approach to be followed in this regard.
    Thanks,
    Alamelu
    null

    Hi Alamelu,
    Make sure you created the type correctly in the database using SQL DDL.
    You can verify that from sqlplus
    sqlplus username/password
    describe typename;
    Here is a code snippet :-
    #define SCHEMA "TKP8ADT1"
    OCITypeByName(envhpx, errhp, svchpx, (const text *) SCHEMA,
    (ub4) strlen((char *)SCHEMA), (const text *) "ADDRESS_VALUE",
    (ub4) strlen((char *)"ADDRESS_VALUE"), (CONST text *) 0,
    (ub4) 0, OCI_DURATION_SESSION, OCI_TYPEGET_HEADER, &addr_tdo);
    thanks,
    Ravi

  • Using VARRAYs as parameters to a Stored Procedure

    I'm trying to pass a VARRAY as an IN/OUT parameter into a simple stored procedure by doing the following ..
    call.addNamedInOutputArgument(.., .., .., oracle.sql.ARRAY.class);
    I'm using a DataReadQuery. I set the call in the query, bind all parameters and add the IN/OUT argument to the query (i.e. query.addArgument(<name>)). Then I create an oracle.sql.ArrayDescriptor to describe the ARRAY.
    ArrayDescriptor ad = ArrayDescriptor.createDescriptor(<name of VARRAY>, <connection>);
    The VARRAY is of size 1 whose type is INTEGER. I create an ARRAY of Integer objects.
    Integer fields[1] = new Integer[1];
    fields[0] = new Integer(2);
    ARRAY a = new ARRAY(ad, <connection>, fields);
    I create a Vector of parameters and add the ARRAY to it. Then I execute the query ..
    Object result = session.executeQuery(<query>, <Vector>);
    When I execute the query I keep getting an ORA-06550: wrong number or types of arguments in call to <stored procedure>. Any help would be appreciated. Thanks. -Michael-

    The workaround above using JDBC directly to call store procedures using VARRAY types is still probably your best solution.
    In TopLink 10.1.3 there is a new API on StoredProcedureCall that allows passing the JDBC type code which should allow binding of VARRAY output parameters.
    addNamedInOutputArgument(String procedureParameterName, String inArgumentFieldName, String outArgumentFieldName, int type, String typeName) {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to call (in PL/SQL) a Procedure with a VARRAY OUT parameter

    Please help, I always get this error:
    PLS-00306: wrong number or types of arguments in call to 'GET_ITEM'
    It's a simple procedure, what is wrong?
    create or replace
    package XXVDF_XPOS_NEW_SALE_TEST as
         type serial_nos               is varray(200)     of     varchar2(20);
    procedure get_item
    (P_SERIALS           IN serial_nos);
    end XXVDF_XPOS_NEW_SALE_TEST;
    create or replace
    package body XXVDF_XPOS_NEW_SALE_TEST as
    procedure get_item
         (P_SERIALS          IN serial_nos)
    is
    begin
         p_serials(1) := 'sdw';
    end get_item;
    end XXVDF_XPOS_NEW_SALE_TEST;
    declare
         type serial_nos               is varray(200) of     varchar2(20);
         P_SERIALS          serial_nos := serial_nos();
    begin
    null;
         XXVDF_XPOS_NEW_SALE_TEST.get_item(P_SERIALS);
         dbms_output.put_line('P_SERIAL_NUMBERS ' ||P_SERIALS(1));
    end;
    thanks, Steve White

    Correction those INs should say OUT:
    create or replace
    package XXVDF_XPOS_NEW_SALE_TEST as
         type serial_nos               is varray(200)     of     varchar2(20);
    procedure get_item
    (P_SERIALS           OUT serial_nos);
    end XXVDF_XPOS_NEW_SALE_TEST;
    create or replace
    package body XXVDF_XPOS_NEW_SALE_TEST as
    procedure get_item
         (P_SERIALS          OUT serial_nos)
    is
    begin
         p_serials(1) := 'sdw';
    end get_item;
    end XXVDF_XPOS_NEW_SALE_TEST;
    declare
         type serial_nos               is varray(200) of     varchar2(20);
         P_SERIALS          serial_nos := serial_nos();
    begin
    null;
         XXVDF_XPOS_NEW_SALE_TEST.get_item(P_SERIALS);
         dbms_output.put_line('P_SERIAL_NUMBERS ' ||P_SERIALS(1));
    end;
    ========
    XXVDF_XPOS_NEW_SALE_TEST.get_item(P_SERIALS);
    ERROR at line 7:
    ORA-06550: line 7, column 2:
    PLS-00306: wrong number or types of arguments in call to 'GET_ITEM'
    ORA-06550: line 7, column 2:
    PL/SQL: Statement ignored

Maybe you are looking for

  • Showing report in Excel

    I'm having trouble trying to show the output for a report in excel. I used the example located at "http://www.oracle.com/technology/products/reports/htdocs/getstart/demonstrations/excel/index.html" I followed the directions exactly I get an "java.lan

  • Changing of Exchange Rate in MIGO via BADI/User Exit

    Hi gurus, I am facing a scenario where I have to amend the exchange rate before posting of GRS. Is there a BADI or User Exit that I could use?

  • MRP  with firm plan orders scenario.

    Dear all, we are in process of MRP implementation. where client having every month a plan of Three months in which first month plan is fixed whereas two months are tentative. to achieve this we have used Planning time fence of 38 days as we run MRP o

  • Assignment of default activity type to individual person

    Hi All, I have following scenario. One maintenance order is created with one operation. Three persons are assigned to the same operation. All these three persons are having different per hour rate and so having different activity types. I have mentio

  • Mouse cursor snaps to point on screen

    I posted this two days ago in the Mac Pro forum, but after searching for a solution since then, I've come to two conclusions: 1) the problem is not a hardware one and 2) using OS X without a mouse is horrendous. Forgive me for copying and editing my