Associative array two variable comparison :update table error

Hi,
i am using associative array to update the version number of table
-i declare two associative array to compare the column from two table (temp,main tables)values in loop
-if id's of both variable(for temp and main table) are equal and column of either of table not matching then it should update the version no of temp table
-if id's not equal i.e record only exists temp table then update null version number annd increment it by 1
-following is the structure and procedure --it shows the matching and non matching records but for the update statement it not giving expected output i.e it updates all records irrespective of the condition provided
-i tried to put condition in update as well as in the  if statement but it updates all record
....suggestion and help highly appreciate. thankx in advance !!!
/*--table structure and data--*/
CREATE TABLE "TEMP_TABLE"
   ( "ID" NUMBER NOT NULL ENABLE,
  "COL1" VARCHAR2(20 BYTE),
  "COL2" VARCHAR2(20 BYTE),
  "VERSION" NUMBER
   INSERT INTO TEMP_TABLE VALUES (101,'A','B',NULL);
   INSERT INTO TEMP_TABLE VALUES (102,'x','y',NULL);
   INSERT INTO TEMP_TABLE VALUES (103,'r','t',NULL);
   CREATE TABLE "MAIN_TABLE"
   ( "ID" NUMBER NOT NULL ENABLE,
  "COL1" VARCHAR2(20 BYTE),
  "COL2" VARCHAR2(20 BYTE),
  "VERSION" NUMBER
   INSERT INTO MAIN_TABLE VALUES (101,'A','B',1);
/*------update version procedure----------*/
DECLARE
  TYPE T_tmp_table IS TABLE OF tmp_table %ROWTYPE INDEX BY PLS_INTEGER;
  TYPE T_main_table IS TABLE OF main_table%ROWTYPE INDEX BY PLS_INTEGER;
  l_tmp_table T_tmp_table;
  l_main_table T_main_table;
  BEGIN
    SELECT * BULK COLLECT INTO l_tmp_table FROM tmp_table;
    SELECT * BULK COLLECT INTO l_main_table FROM main_table;
    FOR i IN 1 .. l_tmp_table.count
    LOOP
      FOR j IN 1 .. l_main_table.count
     LOOP
  if(l_tmp_table(i).ID = l_main_table(j).ID AND l_tmp_table(i).VERSION IS NULL) then     
  ---this first if loop updates temp table version irrespective of l_tmp_table.ID=l_main_table.ID orl_tmp_table. ID<>l_main_table.ID  .it display proper matching and non-matching records.
   dbms_output.put_line('matching ids from tmp and main are :'||l_tmp_table(i).ID||'  '||l_main_table(j).ID);
   UPDATE tmp_table SET VERSION = l_tmp_table(i).version +1;
   --where l_tmp_table(i).ID = l_main_table(j).ID     --
   end if;
  if (l_tmp_table(i).ID <> l_main_table(j).ID) then
   dbms_output.put_line('non matching ids from tmp and main are :'||l_tmp_table(i).ID||'  '||l_main_table(j).ID);
   UPDATE tmp_table SET VERSION = l_tmp_table(i).version +1;
   --where l_tmp_table(i).ID <> l_main_table(j).ID    
    end if;
          END LOOP;
          END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('OTHER');
END;

Hello user8937641
I think there is a problem with the logic of your SQL-Code.
But maybe in this formatted structure you can see where your problem is. -> I can not say it because I do not know what is the requirement.
I hope it helps...
/*------update version procedure----------*/
DECLARE
  TYPE T_tmp_table IS TABLE OF tmp_table %ROWTYPE INDEX BY PLS_INTEGER;
  TYPE T_main_table IS TABLE OF main_table%ROWTYPE INDEX BY PLS_INTEGER;
  l_tmp_table T_tmp_table;
  l_main_table T_main_table;
  BEGIN
    SELECT * BULK COLLECT INTO l_tmp_table FROM tmp_table;
    SELECT * BULK COLLECT INTO l_main_table FROM main_table;
    FOR i IN 1 .. l_tmp_table.count
    LOOP
      FOR j IN 1 .. l_main_table.count
      LOOP
        IF     l_tmp_table(i).ID = l_main_table(j).ID
           AND l_tmp_table(i).VERSION IS NULL
         THEN
             ---this first if loop updates temp table version irrespective of l_tmp_table.ID=l_main_table.ID orl_tmp_table. ID<>l_main_table.ID  .it display proper matching and non-matching records.
             dbms_output.put_line('matching ids from tmp and main are :'||l_tmp_table(i).ID||'  '||l_main_table(j).ID);
             UPDATE tmp_table
                SET version = l_tmp_table(i).version +1;
              WHERE id = l_tmp_table(i).ID
        END IF;
        IF l_tmp_table(i).ID <> l_main_table(j).ID
         THEN
           dbms_output.put_line('non matching ids from tmp and main are :'||l_tmp_table(i).ID||'  '||l_main_table(j).ID);
           -- Maybe you do not need this update:
           UPDATE tmp_table
              SET version = l_tmp_table(i).version +1;
            WHERE id =  l_tmp_table(i).ID
        END IF;
        COMMIT;
       END LOOP;
    END LOOP;
  EXCEPTION WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('Error at Executing the PLSQL-Block - ' || SQLERRM);
END;

Similar Messages

  • Associative Arrays, Indexes vs. Full Table Scans

    Hello,
    I just started using ODP.Net to connect my .Net Web Service to our Oracle Database. The reason why I switched to ODP.Net is support for arrays. If I wanted to pass in arrays to the procedure I had to pass it in through a varchar2 in a CSV formatted string.
    ex. "123,456,789"
    So now I'm using ODP.net, passing in PL/SQL Associative Arrays then converting those arrays to nested tables to use within queries.
    ex.
    OPEN OUT_CURSOR FOR
    SELECT COLUMN1, COLUMN2
    WHERE COLUMN_ID IN (SELECT ID FROM TABLE(CAST(ASSOC_ARR_TO_NESTED(IN_ASSOC_ARR) AS NESTED_TBL_TYPE)))
    It uses the array successfully however what it doesn't do is use the index on the table. Running the same query without arrays uses the index.
    My colleague who works more on the Oracle side has posted this issue in the database general section (link below). I'm posting here because it does seem that it is tied to ODP.Net.
    performance - index not used when call from service
    Has anyone ever experienced this before?

    You have to use a cardinality hint to force Oracle to use the index:
    /*+ cardinality(tab 10) */See How to use OracleParameter whith the IN Operator of select statement

  • Include space between two variables from internal table

    Hi Experts,
    I have an internal table with 4 fields with values for a b c d , i have to arrange them in the specific order so that i can download all the data in a text file.
    the first 3 variables are already arranged , the format is a bc, but the var d should be put in a specific positon after predefined spaces from var c.
    Please refer below for the sample of of the output text file. In this example:
    a = A20N
    b = 7227802
    c = 0300207
    d = 010109
    Space between c & d is determined by a POS variable in internal table
    a        b         c                                          d                       
    A20N 72278020300207                               010109     
    A20A 72278020300207        21     
    A20N 72278020300207          2511100     
    A21F 72278020300207        Van Capellen     
    A21G 72278020300207        Tim     
    A20E 72278020300207                    1     
    A20T 72278020300207        2     
    A20T 72278020300207                                                   1     
    A20E 72278020300207                    01     
    A20E 72278020300207                        Vilvoorde     
    plz help me out as i have to resolve this as soon as possible.

    Hi,
    Check this sample code using offsets, and modify as per ur requirement.
    DATA : L1 TYPE I.
    DATA : L2 TYPE I.
    DATA : L3 TYPE I.
    DATA : BEGIN OF ITAB OCCURS 0,
           A(30) TYPE C,
           B(30) TYPE C,
           C(30) TYPE C,
           D(30) TYPE C,
           POS(2) TYPE C,
           END OF ITAB.
    DATA : TEXT(120) TYPE C.
    START-OF-SELECTION.
    BREAK-POINT.
      ITAB-A = 'ABC'.
      ITAB-B = 'IND'.
      ITAB-C = 'CATOR'.
      ITAB-D = 'FINAL'.
      ITAB-POS = '3'.
      APPEND ITAB.
      CLEAR ITAB.
      LOOP AT ITAB.
        L1 = STRLEN( ITAB-A ).
        L2 = STRLEN( ITAB-B ).
        L3 = STRLEN( ITAB-C ).
        TEXT = ITAB-A.
        L1 = L1 + 1.
        TEXT+L1 = ITAB-B.
        L1 = L1 + L2.
        TEXT+L1 = ITAB-C.
        L1 = L1 + L3 + ITAB-POS.
        TEXT+L1 = ITAB-D.
        CLEAR L1.
        CLEAR L2.
        CLEAR L3.
      ENDLOOP.
      WRITE : TEXT.
    Rgds
    siva

  • Comparing two records from different tables error.

    Hi folks!
    I have this PL/SQL Block.
    I want to compare the only one record from both tables to see if the content of them are equal or not, but I don't want to specified column by column to do that.
    Any idea?
    Thanks a lot in advanced,
    Abdel E. Miranda S.
    Panama
    declare
    cursor c_aems_prueba is
    select nombre, direccion, telefono, limite, seq
         from aems_prueba;
    cursor c_aems_testing is
    select nombre, direccion, telefono, limite, seq
         from aems_testing;
    vc_aems_prueba c_aems_prueba%rowtype;
    vc_aems_testing c_aems_testing%rowtype;
    vt_aems_prueba aems_prueba%rowtype;
    vt_aems_testing aems_testing%rowtype;
    begin
    insert into aems_prueba
    values('ABDEL MIRANDA', 'PAITILLA', '215-3411', 1000, 1);
    insert into aems_testing
    values('ABDEL MIRANDA', 'PAITILLA', '215-3411', 1000, 1);
    commit;
    open c_aems_prueba;
    fetch c_aems_prueba into vt_aems_prueba;
    open c_aems_prueba;
    fetch c_aems_prueba into vt_aems_testing;
    if vt_aems_prueba = vt_aems_prueba
    then
         dbms_output.put_line('son iguales las variables, si funciona la comparacion de dos estructuras');
         else
         dbms_output.put_line('no son iguales las variables, no funciona la comparacion de dos estructuras');
    end if;
    close c_aems_prueba;
    close c_aems_testing;
    end;

    Satyaki De,
    Java is involving because an Outsourcing new project. The outsourcing company is developing the new application using JSF which invoke an interface java method [depending of the operation: select, update, insert] and them invoke the PLSQL API to precess tha operation.
    In the case I already wrote here, the issue is this:
    The user search for a specific data using the interface. The java method send a request for these operation through the API. the PLSQL process the request and return a beam, with all the column the user look for.
    The user see the information in the application windows. Assuming the user wants to change some data, he modify just one field [lets say telephone number] and press the update button. The application process the request using a different method, which invoke a different function within the PLSQL API.
    Once the information is returning to the API, I must know if at least one field change its value. So I was thinking to get the beam with the data before it was changed and compare it with the beam with the changing data.
    If current_beam = new_beam
    then
    update
    else
    no change to process
    end if;
    Any idea.

  • Update Table Error

    Hi,
    I am unable to update SRID in Geoemetry. I am getting the following error on update.
    Update cad_2001 C
    set C.Geometry.SDO_SRID=2950;
    ora-29877 failed in the execution of the odciindexupdate routine
    Ora-13365 layer SRID does not match geometry SRID
    Ora-06512 at MDSYS.sdo_index_method_101 line 270
    I have also updated SRID '2958' in USER_SDO_GEOM_METADATA but no effect.
    Does something wrong with my Geometry?
    My Geometry 1st row is
    SQL> select geometry from cad_2001 where rownum <=1;
    GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    SDO_GEOMETRY(3001, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 0, 6000, 4, 1, 1), SDO_ORD
    INATE_ARRAY(1, 0, 0, 609159.084, 4843290.05, 0))
    Thanks
    Nancy

    You first have to drop the spatial index before you can update the SRID.
    siva

  • Associative Array vs Table Scan

    Still new to PL/SQL, but very keen to learn. I wondered if somebody could advise me whether I should use a collection (such as an associative array) instead of repeating a table scan within a loop for the example below. I need to read from an input table of experiment data and if the EXPERIMENT_ID does not already exist in my EXPERIMENTS table, then add it. Here is the code I have so far. My instinct is that it my code is inefficient. Would it be more efficient to scan the EXPERIMENTS table only once and store the list of IDs in a collection, then scan the collection within the loop?
    -- Create any new Experiment IDs if needed
    open CurExperiments;
    loop
    -- Fetch the explicit cursor
    fetch CurExperiments
    into vExpId, dExpDate;
    exit when CurExperiments%notfound;
    -- Check to see if already exists
    select count(id)
    into iCheckExpExists
    from experiments
    where id = vExpId;
    if iCheckExpExists = 0 then
    -- Experiment ID is not already in table so add a row
    insert into experiments
    (id, experiment_date)
    values(vExpId, dExpDate);
    end if;
    end loop;

    Except that rownum is assigned after the result set
    is computed, so the whole table will have to be
    scanned.really?
    SQL> explain plan for select * from i;
    Explained.
    SQL> select * from table( dbms_xplan.display );
    PLAN_TABLE_OUTPUT
    Plan hash value: 1766854993
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |   910K|  4443K|   630   (3)| 00:00:08 |
    |   1 |  TABLE ACCESS FULL| I    |   910K|  4443K|   630   (3)| 00:00:08 |
    8 rows selected.
    SQL> explain plan for select * from i where rownum=1;
    Explained.
    SQL> select * from table( dbms_xplan.display );
    PLAN_TABLE_OUTPUT
    Plan hash value: 2766403234
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |     1 |     5 |     2   (0)| 00:00:01 |
    |*  1 |  COUNT STOPKEY     |      |       |       |            |          |
    |   2 |   TABLE ACCESS FULL| I    |     1 |     5 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter(ROWNUM=1)
    14 rows selected.

  • Associative array comparison and INSERT upon IF condition

    Hi Guys,
    I have written this pl sql code to identify non existing sellers and insert their sales channel information into the dimension table (dimensional table update).
    Somehow,......nothing is inserted and this script runs for 12 hours+ without any result. the sql autotrace shows no result and the explain plan (button on sql developer throws upon clicking "missing keyword". I have no
    information what is going on/wrong. Does anyone spot an error?
    UNDEFINE DimSales;
    UNDEFINE FactTable;
    DEFINE DimSales = 'testsales';
    DEFINE FactTable = 'testfact';
    DECLARE
    v_SellerNo VarChar(9);
    v_error_code T_ERRORS.v_error_code%TYPE;
    v_error_message T_ERRORS.v_error_message%TYPE;
    TYPE assoc_array_str_type1 IS TABLE OF VARCHAR2(32) INDEX BY PLS_INTEGER;
         v1 assoc_array_str_type1;
    TYPE assoc_array_str_type2 IS TABLE OF VARCHAR2(32) INDEX BY PLS_INTEGER;
         v2 assoc_array_str_type2;
    BEGIN
    --Collect all distinct SellerNo into associative array (hash table)
    select distinct SellerNo bulk collect into v1 from &FactTable;
    select distinct seller_id bulk collect into v2 from &DimSales;
    v_SellerNo := v1.first;
    loop
    exit when v1 is null;
    --1 Check if v_SellerNo already exists in DIM_Sales (if NOT/FALSE, its a new seller and we can insert all records for that seller
    if (v2.exists(v_SellerNo)=false) THEN
    INSERT INTO &DimSales (K_Sales,REG,BVL,DS, VS,RS,GS,VK)
    (SELECT DISTINCT trim(leading '0' from RS||GS) ,REG BVL,DS,VS,RS,GS,VK from &FactTable where SellerNo =v_SellerNo);
    --ELSE
    end if;
    v_SellerNo := v1.next(v_SellerNo);
    end loop;
    EXCEPTION
    WHEN OTHERS THEN
    ROLLBACK;
    --v_error_code := SQLCODE
    --v_error_message := SQLERRM
    --INSERT INTO t_errors VALUES ( v_error_code, v_error_message);
    END;
    ---------------------------------------------------------------

    Distinct clause requires a sort. Sorts can be very expensive.
    Bulk collects that are not constrained in fetch size, can potentially fetch millions of rows - requiring that data to be wholly read into server memory. I have seen how this can degrade performance so badly that the kernel reboots the server.
    Using PL/SQL loops to process and insert/update/delete data is often problematic due to its row-by-row approach - also called slow-by-slow approach. It is far more scalable letting SQL do the "loop" processing, by using joins, sub-selects and so on.
    Where the conditional processing is too complex for SQL to handle, then PL/SQL is obviously an alternative to use. Ideally one should process data sets as oppose to rows in PL//SQL. Reduce context switching by using bulk fetches and bulk binds.
    But PL/SQL cannot execute in parallel as the SQL it fires off can. If after all the optimisation, the PL/SQL process still needs to hit a million rows to process, it will be slow irrespective of how optimal that PL/SQL approach and design - simply because of the number of rows and the processing overheads per row.
    In that case, the PL/SQL code itself need to be parallelised. There are a number of ways to approach this problem - the typical one is to create unique and distinct ranges of rows to process, spawn multiple P/SQL processes, and provide each with a unique range of rows to process. In parallel.
    So you need to look close at what you are trying to achieve, what the workloads are, and how to effectively decrease the workloads and increase the processing time of a workload.
    For example - finding distinct column values. You can pay for that workload when wanting that distinct list. And each time afterward repeat that workload when wanting that distinct list. Or you can pay for that workload up-front with the DML that creates/updates those values - and use (for example) a materialised view to maintain a ready to use distinct list of values.
    Same workload in essence - but paying once for it and up-front as oppose to each time you execute your code that needs to dynamically build that distinct list.
    Kent Crotty did tests and showed stunning performance improvements with bulk collect and forall, up to 30x faster:Bulk processing is not a magical silver bullet. It is a tool. And when correctly use, the tool does exactly what it was designed to do.
    The problem is using a hammer to drive in screws - instead of a screwdriver. There's nothing "stunning" about using a screwdriver. It is all about using the correct tool.
    If the goal of the swap daemon is to free up "idle" chunks of memory, and try to use that memory for things like file cache instead, what does that have to do with bulk processing?The swap daemon reads virtual memory pages from swap space into memory, and writes virtual pages from memory to swap space.
    What does it have to do with bulk processing? A bulk fetch reads data from the SGA (buffer cache) into the PGA (private process memory space). The larget the fetch, the more memory is required. If for example 50% of server memory is required for a bulk collection that is 2GB in size, then that will force in-use pages from memory to swap space.. only to be swapped back again as it is needed, thereby forcing other in-use pages to swap. The swap daemon will consume almost all the CPU time swapping hot pages continually in and out of memory.

  • Associative Array error

    I am using a couple associative arrays in my code and comparing the data in one, and if it is an asterisk, I change it to use the data in the other. Here is the meat of my code. I am running into an error at the bolded line saying I have too many values, which I don't understand because the code is the exact same as the block of code right before it where I populate the first array. FYI, the table it is pulling from only has one row. The error is listed below the code.
    Code
    DECLARE
    TYPE refresh_file_t IS TABLE OF test.loading_dock%ROWTYPE ;
    refresh_data refresh_file_t ;
    prospect_data refresh_file_t ;
    TYPE CV_TYPE IS REF CURSOR ;
    c_id CV_TYPE ;
    v_id NUMBER(10) ;
    v_phone VARCHAR2(10) ;
    v_project VARCHAR2(10) ;
    BEGIN
    OPEN c_id FOR
    'SELECT id
    FROM test.loading_dock
    WHERE rownum = 1' ;
    LOOP
    FETCH c_id INTO v_id ;
    EXIT WHEN c_id%NOTFOUND ;
    SELECT * BULK COLLECT
    INTO refresh_data
    FROM test.loading_dock
    WHERE id = v_id ;
    SELECT * BULK COLLECT
    INTO prospect_data
    FROM test.prospects
    WHERE id_number = v_id ;
    IF refresh_data(1).home_phone = '*' THEN
    v_phone := prospect_data(1).phone ;
    ELSE
    v_phone := refresh_data(1).home_phone ;
    END IF ;
    DBMS_OUTPUT.PUT_LINE(v_phone) ;
    END LOOP ;
    CLOSE c_id ;
    END ;
    Error
    ORA-06550: line 29, column 13:
    PL/SQL: ORA-00913: too many values
    ORA-06550: line 27, column 13:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 34, column 46:
    PLS-00302: component 'PHONE' must be declared
    ORA-06550: line 34, column 13:
    PL/SQL: Statement ignored
    06550. 00000 - "line %s, column %s:\n%s"

    Collection prospect_data is of type refresh_file_t, which is a table of records of test.loading_dock%TYPE. Most likely tables test.loading_dock and test.prospects have different structure - test.prospects has fewer columns. So when you try to fetch from test.prospects into prospect_data you get the error Try replacing
    prospect_data refresh_file_t ;with
    TYPE prospect_data_t IS TABLE OF test.prospects%ROWTYPE ;
    prospect_data prospect_data_t ;SY.

  • Error while assigning dates to associative array of date type

    Hi All,
    I am facing the issue while assigning dates to associative array of date type:
    Oracle Version:
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Stored procedure i am trying to write is as following
    create or replace procedure jp1 (
    p_start_date date default trunc(sysdate,'MM')
    , p_end_date date default trunc(sysdate)
    is
    l_no_of_days number;
    type t_date_id is table of date
    index by pls_integer;
    l_date_id_arr t_date_id;
    begin
    l_no_of_days := p_end_date - p_start_date;
    for i in 0
    .. l_no_of_days - 1
    loop
        l_date_id_arr := p_start_date + i;
        dbms_output.put_line(p_start_date + i);
    end loop;
    end;
    I am getting error at line 14 while compiling this. and the error message is as following:
    Errors for PROCEDURE JP1:
    LINE/COL ERROR
    14/5     PL/SQL: Statement ignored
    14/22    PLS-00382: expression is of wrong type
    So while investigating this i tried to output the value of (p_start_date + i) using dbms_output.put_line and the output is date itself.
    create or replace procedure jp1 (
    p_start_date date default trunc(sysdate,'MM')
    , p_end_date date default trunc(sysdate)
    is
    l_no_of_days number;
    type t_date_id is table of date
    index by pls_integer;
    l_date_id_arr t_date_id;
    begin
    l_no_of_days := p_end_date - p_start_date;
    for i in 0 .. l_no_of_days-1
    loop
        --l_date_id_arr := p_start_date + i;
        dbms_output.put_line(p_start_date + i);
    end loop;
    end;
    output of the
    exec jp1
    is as following:
    01-DEC-13
    02-DEC-13
    03-DEC-13
    04-DEC-13
    05-DEC-13
    06-DEC-13
    07-DEC-13
    08-DEC-13
    09-DEC-13
    10-DEC-13
    11-DEC-13
    12-DEC-13
    13-DEC-13
    14-DEC-13
    15-DEC-13
    16-DEC-13
    17-DEC-13
    18-DEC-13
    I see the output as date itself. so why it is throwing error while assigning the same to associative array of date type.
    I tried to google also for the same but to no avail.
    Any help in this regard is appreciated or any pointer some other thread on internet or in this forum.
    Thanks in advance
    Jagdeep Sangwan

    Read about associative arrays :
    create or replace procedure jp1 (
    p_start_date date default trunc(sysdate,'MM')
    , p_end_date date default trunc(sysdate)
    ) is
    l_no_of_days number;
    type t_date_id is table of date
    index by pls_integer;
    l_date_id_arr t_date_id;
    begin
    l_no_of_days := p_end_date - p_start_date;
    for i in 0..l_no_of_days - 1
    loop
        l_date_id_arr(i) := p_start_date + i;
        dbms_output.put_line(p_start_date + i);
    end loop;
    end;
    Ramin Hashimzade

  • Error in the pl/sql block using associative arrays

    Hi
    I tried the following block of code using associative arrays.
    DECLARE
       TYPE NumTab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
       CURSOR c1 IS SELECT empno FROM emp;
       empnos NumTab;
       rows   NATURAL := 10;
    BEGIN
       OPEN c1;
       FOR i in empnos.first..empnos.last LOOP
          /* The following statement fetches 10 rows (or less). */
          FETCH c1 BULK COLLECT INTO empnos LIMIT rows;
          EXIT WHEN c1%NOTFOUND;
          DBMS_OUTPUT.PUT_LINE ( empnos.next(i));
       END LOOP;
       CLOSE c1;
    END;and the error is
    DECLARE
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at line 8could you please let me know where i'm wrong
    and please guide me where we use these associative arrays.
    Thanks

    Something like this. Do minor modification in your code.
    DECLARE
       TYPE NumTab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
       CURSOR c1 IS SELECT empno FROM emp;
       empnos NumTab;
       rows   NATURAL := 5;
    BEGIN
       OPEN c1;
       LOOP  
        /* The following statement fetches 5 rows (or less). */
          FETCH c1 BULK COLLECT INTO empnos LIMIT rows;
          EXIT WHEN c1%NOTFOUND;
          DBMS_OUTPUT.PUT_LINE ( empnos.count);
       END LOOP;
       CLOSE c1;
    END;
    /

  • Two forms that update differrent tables on the same page?

    I tried to add two forms that update different tables on to one page.
    Problem is when I do that the forms gives me an error saying the field does not exist. It's like it is trying to update one table with the other tables fields.
    As an example Say I have one forms that is for people table and another one that is the Jobs table.
    When I go to update the people table, it sends the data for the jobs fields too I get an error like the field job description does not exist.
    I have two different forms for these and everything.
    I would hope it is possible to have two forms that update different tables on the same page.

    I was trying the exact same thing, but i managed to work round it by setting the steps to hide one region, so the user would enter the form see one region submit the region then direct back to the same page with the different region visible and the original hidden.
    I don't know if this would be acceptable for you...

  • Error updating table 372"

    Hi friends,
    when iam generating a excise invocie the system triggers"Error updating table 372"
    Any possible solution for this?
    Thanks
    Ivy

    Dear All,
    I done this--by doing some configuration changes.
    Normally while doing Exports we are tempted to use the same sales area and accordingly we may give the combination of excise grp+series grp+export type in IMG>>>Logistics General>>>India>>>Business transactions>>>Outgoing excise invoices>>>Maintain default excise groups and series groups.
    Once after removing the export type to your sales area combination--system will show this error--and we cannot even post the Excise invoices.(J1IIN)
    I tried in my IDES--that with export type(Ex.Export under Bond)--with this assignment--i am able to post my excise invoices.
    Once after removing this assignment of export type--again i am getting this error.
    Actually i am not even aware why it is happening--almost after two months of struggle--i find this.
    (i feel it is in the same way that we cannot even open/See a sales order by deleting sales group which was created&used previously)
    i am sharing this because somebody may get a little help with my thread.
    Mark this if helpful--there by others can easily find this thread.
    Phanikumar

  • "Error in updating Table J_1iexchdr"

    Hi ,
    When I am creating the excise invoice, It's terminated the program and gives the following error
    "Error in updating Table J_1iexchdr"
    What can be the reason?
    Regards
    Prem

    Hi prem
    Look if these threads can help
    RG23C Update Problem
    Problem in SAP Script
    billing document not creating
    return delivery
    ************Reward points if usefull**************

  • Error in updating table J_1PART2

    Hi,
       I am getting an error while saving the excise invoice as 'error in updating table J_1PART2'.
    What would have gone wrong?????? please help!!!
    Thanks ,
    Ramya

    Discussion moved from SAP ERP Sales and Distribution (SAP SD) to Internationalization and Unicode
    Please use Internationalization and Unicode for you CIN related queries

  • Error in updating table J_1IEXCHDR,J_1IEXCDTL in tcode J1IJ

    Hi,
    while cancelling excise invoice in Tcode J1IJ ,
    we are getting 'error in updating table J_1IEXCHDR,J_1IEXCDTL'.
    what is missing or tell the procedure to resolve the issue.
    Regards,

    Discussion moved from SAP ERP Sales and Distribution (SAP SD) to Internationalization and Unicode
    Please use Internationalization and Unicode for you CIN related queries

Maybe you are looking for