How to: compare 2 associative arrays element-by-element

After playing, I decided to go with the approach of the two sets of data of their own associative array.  The code and the results of this are below.  My question is the comparison.  For each element within the matrix of order, check all the items in the details table to see if there's a football game.  If there is a match > > > move to the next item in the control panel and check all the items in the details table to see if there is a football game.  Go until the whole is considered to be a match (in number of rows and values).  If no match, take the exit.

Below, you'll see my logic to get both sets of data into their respective tables.  The results with a note attached to one of the elements is also pasted here (hereinafter the code).

DECLARE

TYPE details_t () IS RENDERING

SIDE AUTO_RECIPE_DETAILS. SIDE % TYPE.

REF_DES AUTO_RECIPE_DETAILS. REF_DES % TYPE,

PART_NUM AUTO_RECIPE_DETAILS. PART_NUM % TYPE

);

TYPE details_type IS TABLE OF details_t INDEX OF AUTO_RECIPE_DETAILS. PART_NUM % TYPE;

details_recipe details_type;

pid_recipe details_type;

compare_result details_type;

CURSOR details_cur

IS

SELECT A FACE, REF_DES, PART_NUM

OF AUTO_RECIPE_DETAILS

WHERE RECIPE_NAME =' 40617-000001;

CURSOR pid_cur

IS

SELECT cl. SIDE, lacpa. REF_DES, NVL(oecl.COMPONENT_ID, 'NOT APPLIED') AS PART_NUM

OF ORDER_ERP_COMPS_LIST lacpa

RIGHT OUTER JOIN CAD_LOCS cl

ON cl. REF_DES = LACPA. REF_DES

WHERE lacpa. ORDER_NUM = "PSY142420."

AND CL. FAB = '38112';

counter_d number (10): = 0;

counter_p number (10): = 0;

comp_counter number (10): = 0;

BEGIN

FOR rec IN details_cur

LOOP

counter_d: = counter_d + 1;

details_recipe (counter_d). SIDE: = rec. SIDE;

details_recipe (counter_d). REF_DES: = rec. REF_DES;

details_recipe (counter_d). PART_NUM: = rec. PART_NUM;

END LOOP;

FOR rec IN pid_cur

LOOP

counter_p: = counter_p + 1;

pid_recipe (counter_p). SIDE: = rec. SIDE;

pid_recipe (counter_p). REF_DES: = rec. REF_DES;

pid_recipe (counter_p). PART_NUM: = rec. PART_NUM;

END LOOP;

-for each pid_recipe element, double-check each record in details_recipe to see if there is an item matching (record)...

FOR indx_d IN details_recipe. FIRST... details_recipe. LAST

LOOP

DBMS_OUTPUT. Put_line (details_recipe (indx_d). SIDE | ', ' || details_recipe (indx_d). REF_DES | ', ' || details_recipe (indx_d). PART_NUM);

END LOOP;

DBMS_OUTPUT. PUT_LINE ('IN THE SECOND PART OF IT!');

FOR indx_p IN pid_recipe. FIRST... pid_recipe. LAST

LOOP

DBMS_OUTPUT. Put_line (pid_recipe (indx_p). SIDE | ', ' || pid_recipe (indx_p). REF_DES | ', ' || pid_recipe (indx_p). PART_NUM);

END LOOP;

END;

/



RESULT:


DETAILS TABLE

RECIPE FOR THE DETAILS TABLE:

B, R28, 34315-26R7

B, R38, 34315-4990

B, R40, 34152-1R60

B, R45, 34315-1002

B, R46, 34315-3011

B, R48, 34152-1004

B, R55, 34315-5901

B, R64, NOT APPLIED

B, R77, 34315-4992



CONTROL PANEL

THE RECIPE IS CALCULATED IN THE ORDER ITSELF:

B, C01, 39412-334 / / for that one single item-> check all the items from the table (above) details Table and see if an element matches.  Move to the next item if there is a match...

B, C02, 39412-334

B, C03, NOT APPLIED

T, C11, 27249-105

T, C13, 35404-104

T, C14, 27531-224

T, C15, 35404-104

T, C18, 27249-105

T, C19, 27531-224

CHANGED:

THIS... is the solution to my original question.  I had a little mistake that I set between this and my last post with this code.  Just in case a person who could use an example like that falls on this thread.

FOR index_p IN pid_recipe. FIRST... pid_recipe. LAST

LOOP

Result WHEN the OUTPUT = 1;

FOR index_d IN details_recipe. FIRST... details_recipe. LAST

LOOP

IF (pid_recipe (index_p). SIDE = details_recipe (index_d). SIDE)

AND (pid_recipe (index_p). REF_DES = details_recipe (index_d). REF_DES)

AND (pid_recipe (index_p). PART_NUM = details_recipe (index_d). PART_NUM)

THEN

EXIT;

ON THE OTHER

DBMS_OUTPUT. Put_line("IT WAS NOT a MATCH");

result: = 1;

EXIT;

END IF;

END LOOP;

END LOOP;

DBMS_OUTPUT. Put_line('LOOP OUT');

Tags: Database

Similar Questions

  • How to create an associative array

    Is it necessary to creat a table associated with?
    index by BINARY_INTEGER
    CREATE OR REPLACE TYPE WEBINST.string_state_table AS TABLE OF varchar2(100) ;

    Yes,

    You must use the index by clause to create an associative array. Other wise, it is called as a nested table.

    Read this

    http://download.Oracle.com/docs/CD/B28359_01/AppDev.111/b28370/Collections.htm#i34563

    See how you can declare the different collections

    http://download.Oracle.com/docs/CD/B28359_01/AppDev.111/b28370/Collections.htm#CJAJEIBA

    G.

  • How to share an associative array throughout the entire instance?

    Hi all

    I have an associative array containing a lot of data and it would barely change, I want to keep in memory and share all throughout the entirety of an instance and make sure that all the sessions for all users, get the same table associative, is - it possible?

    Thanks in advance.

    >

    I just want to keep it in memory and share them throughout the entire instance and make sure that all sessions of all users get the same associative array, is it possible?

    Why do you want to keep in mind?
    Will using a table for it, who has access frequently, almost will always be in the buffer cache, performance of the cause of the problems for you?

    The only other way to keep the data in memory in the world FLEURIDAS to all database sessions is to use the global application context functionality. With which you can store [name, value] pairs in memory and easily (read) access using integrated SYS_CONTEXT.

    Toon

  • compare the two array element and ignore the undesirable element of the array

    Hello

    Here I attached the vi. In this vi I compare table with ideal picture of A to z. normally in an entry, that we get a data with noise, as is show in this vi normally I just need to compare the value has Cwith c D with D with A & B with B, and so on. now the problem is I have to compare ideal picture with input .and string array if the input string is not in series from A to Z the whole comparion is .i false hope you understand my problem and give some suggestion thank you

    Please take a look at this modified version of your code and I would like to know if that's what you are trying to achieve.

    Please, ask questions and make sure you are comfortable and understand what I coded.

  • How to compare one by an element of a column with the first column in the other table?

    Hello

    I have two files into a single file has only Id numbers and the second file has table with for example the column 4, and his first column identification number.

    So I want to compare the first item in the User.ID file with the 1st column all the table file items in this column until it finds matches.

    If compare match then LED will be IT other wise LED will be OFF.

    Here as an attachment, I've attached the two file.

    Please guide me how can I do the same thing.

    Thank you much in advance.


  • Associative array in an array?

    I joined a project to a flash game, and being the only one that has any type of coding experience, I have, of course, make the ActionScript.

    However, the coding I did that day where, in PHP, not in ActionScript.

    so, even if we just started, I have a problem:

    I need to create a list of objects and enemies, that the game has.

    the elements? No problem:

    var items:Array = new array("Coin", "Tools",.....);
    

    so which works fine now, but the bad guys are not a problem, now, I have the same base table.

    Yet I need an associative array in another associative array.

    Since I have no idea how to do this in ActionScript, this is what I mean, but in the State would be in PHP:

    array("enemy_1" => array("drops" => "coins/10", "requires" => "credits/100"), "enemy_1" => array("drops" => "tool/ Screwdriver")....)

    So I have an associative array of names of the enemy, and those who are associated with a new table showing information on the enemy.

    problem is that the above is PHP and I need that in ActionScript, I can figure out how to do an associative array, but not if you can pass an associative array as its value.

    Look into the Dictionary and Vector classes. Or just use the Object.

  • An associative array, how the records using the loop counter?

    In the associative array, how the records using the loop counter? for example
    declare
        type population is table of number index by varchar2(64);
        city_population population;   
    begin
        city_population('Samillve') := 200;
        city_population('Lindenhurst') := 300;    
        
        for i in 1 .. city_population.count
        loop
            dbms_output.put_line(city_population(i)); -- compiler error
        end loop;
    end;
    /

    That would look like

    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2      type population is table of number index by varchar2(64);
      3      city_population population;
      4      l_index varchar2(64);
      5  begin
      6      city_population('Samillve') := 200;
      7      city_population('Lindenhurst') := 300;
      8      l_index := city_population.first;
      9      while( l_index IS NOT NULL )
     10      loop
     11          dbms_output.put_line(city_population(l_index ));
     12          l_index := city_population.next(l_index);
     13      end loop;
     14* end;
    SQL> /
    300
    200
    
    PL/SQL procedure successfully completed.
    

    Justin

  • How to access an array element?

    I'm trying to access a table on a click of a button element.  Complete creation, I have this: var = students ["Theo Arguna", "Leif Arneson", 'John Egan', "Sakura Nakahara", 'Rebecca Pilkington', "Debra Sutter"];

    the passage of the mouse button I put this:

    var myVariable = sym.getVariable("students.eq[0]");

    sym.getSymbol("message").$("Text4").html ("Click now to see" + sym.getVariable ("myVariable") + "working.");

    When I test I get "undefined" say where "$myvariable" is in the line above the code.

    Any suggestions on how to get the array element in this?

    Hello

    «"«You are almost there...»»»

    Put this in your creationComplete event:

    sets the variables table students

    sym.setVariable ("students", ["Theo Arguna", "Leif Arneson", "John Egan", "Sakura Nakahara", "Rebecca Pilkington", "Debra Sutter"]);

    And put it in your button mouseover event:

    get the array element you want

    var myVariable = sym.getVariable ("students") [0];

    sym.getSymbol("message").$("Text4").html ("Click now to see" myVariable + "working.");

    HTH,

    Joe

  • How to get the 'index' of an associative array?

    Hello

    Is it possible to get the 'index' of an associative array?

    I saw say about 3000 ID.

    Corresponding to each of these identifiers, thre is a 'key' (the 'key' can repeat for different ID)... tell key1, key2, key3.

    Now, I want to show the top of page 8 keys ().

    Could you please tell me how can I do this?

    Concerning

    Don't know what you are exactly looking for.

    To get the index of an array of assotiative you should do something like

    SQL> declare
       type arr is table of number
                      index by varchar2 (5);
    
       var   arr;
       idx   varchar2 (5);
    begin
       --  fill the array
       for id in 1 .. 12
       loop
          var ('key' || to_char (id, 'fm00')) := id;
       end loop;
    
    --  get the keys
       idx := var.first;
       dbms_output.put_line (idx);
    
       while idx is not null
       loop
          idx := var.next (idx);
          dbms_output.put_line (idx);
       end loop;
    end;
    /
    key01
    key02
    key03
    key04
    key05
    key06
    key07
    key08
    key09
    key10
    key11
    key12
    PL/SQL procedure successfully completed.
    
  • How can you specify the default value for the undefined array elements

    According to aid LV, the tables have two default values, the normal default value and the default value for the undefined array elements.

    I assume that there must be a way to specify the default value for later, but I can't find it anywhere.  Any ideas?

    I know that you can drag the item out of the table container.  Change the default value on this scalar element.  Then drag the item in table tank.

  • How to see the output of an associative array in procedure

    Hello
    I tried the following code
    And confused about the research at the exit of the associative array.
    CREATE OR REPLACE PACKAGE test_pak1
    AS
       FUNCTION map_object (obj_typ_in VARCHAR2)
          RETURN VARCHAR2;
    
       CURSOR c_c1
       IS
          SELECT * FROM emp;
    
       TYPE test_ttyp IS TABLE OF c_c1%ROWTYPE
                            INDEX BY PLS_INTEGER;
    
       PROCEDURE search_obj (obj_type VARCHAR2);
    END;
    
    CREATE OR REPLACE PACKAGE BODY test_pak1
    AS
       FUNCTION map_object (obj_typ_in VARCHAR2)
          RETURN VARCHAR2
       IS
       BEGIN
          dopl ('Hello');
          RETURN abc;
       END;
    
       PROCEDURE search_obj (obj_type VARCHAR2)
       IS
          test_tab   test_ttyp;
       BEGIN
            DOPL  (test_tab);
          end;
       END;
    In the above code, I want to see the output of the test_tab located in the search_obj procedure.

    could you please help me in this

    Thank you

    Hi, smile,

    If you want to see records, you must put the lines in your table. Here's a solution: in this solution, I only edit the search_obj procedure of your package like this:

     PROCEDURE search_obj (obj_type VARCHAR2)
       IS
          test_tab   test_ttyp;
          test_tab_r   c_c1%ROWTYPE;
       BEGIN
            --test_tab;
            --Here we put something in test_tab
            OPEN c_c1;
    
            LOOP
                 Fetch c_c1 into test_tab_r;
                 exit when c_c1%NOTFOUND;
                 test_tab(test_tab.COUNT + 1) := test_tab_r;
             END LOOP;
            CLOSE c_c1;   
    
            FOR i IN 1 .. test_tab.COUNT LOOP
              dbms_output.put_line(test_tab(i).empno);
           END LOOP;
    
       END;
    

    Here is the result:

    SQL> exec test_pak1.search_obj('parameter_not_used_in_the_procedure');
    7369
    7499
    7521
    7566
    7654
    7698
    7782
    7788
    7839
    7844
    7876
    7900
    7902
    7934
    
    PL/SQL procedure successfully completed.
    
    SQL>
    
  • How to compare the original value of table size and the changed value

    juice I took a table and then took the function of the size of the array so that it shows me the number of the elements present in it. so it'll be the original table size value. If the items in the table even changes another value, then I want to compare the original table size value and the value of table size has changed. How to compare... Please help me. you are looking for a possible solution. Thank you

    Hi stara,

    the attached picture shows the ony solution.

    It will be useful.

    Mike

  • Cannot run the autonomous block for input of associative array parameter

    Hello

    I have created an associative array in a package-PKG_CMT_DAP

    TYPE r_supply_type_id IS RECORD(
                                   supply_type_id            varchar2(50));
    TYPE t_supply_type_id IS TABLE OF r_supply_type_id INDEX BY BINARY_INTEGER;
    l_supply_type_id t_supply_type_id;
    

    Later created a test procedure with an input of the above kind parameter

    create or replace
    procedure test_prc(p_in_st_id IN PKG_CMT_DAP.t_supply_type_id)
    AS
    v_input1 number;
    v_input2 number;
    BEGIN
    FOR z IN 1..p_in_st_id.COUNT 
    LOOP
    DBMS_output.put_line(p_in_st_id(z)supply_type_id);
    END LOOP;
    END test_prc;
    

    How to update successfully.

    Created a stand-alone as block below

    DECLARE
    BEGIN
    test_prc(p_in_st_id=>(100,200,300));
    END;
    

    Above am past in 100,200,300 as an input string, and the expected output should display all the numbers above on the screen.

    But it throws the below error

    Error report:
    ORA-06550: line 3, column 1:
    PLS-00306: wrong number or types of arguments in call to 'TEST_PRC'
    ORA-06550: line 3, column 1:
    PL/SQL: Statement ignored
    06550. 00000 -  "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:
    

    Could you please help me where I am doing wrong?

    Kind regards

    Claudy Kotekal

    Claudy,

    While calling the procedure, you must declare the variable of type table. Give the values for the elements in the begin block and then pass that variable in the procedure. Something like below:

    Declare

    in_array PKG_CMT_DAP. r_supply_type_id;

    Begin

    in_array (1) .supply_type_id: = 100;

    in_array (2) .supply_type_id: = 200;

    in_array (3) .supply_type_id: = 300;

    test_prc (in_array);

    end;

    NOTE: There might be a few problems with my code syntax, but logic would be same.

    Try this and let me know.

    Thank you

  • need help in the associative arrays indexed by varchar

    Hi, I wanted to fill an associative array that is indexed by varchar, but I'm confused by incrementing the pointer so that the next lines gets inserted into the next available place.
    sample data:
    type ty_tb_tab_acc is record (account varchar2 (30));
    type ty_tb_indx_acct is table of index ty_tb_tab_acc by varchar2 (35);

    cursor sampls_cursor is
    Select an account in sam_tab where the clause goes in here

    say that my cursor returns 20 accounts. now, I want these 20 accounts will be inserted in the table associative ty_tb_indx_acct
    How should I buckle and incrment table?

    Please share your ideas

    user13710379 wrote:
    If this isn't the case, associatve tables approach I should use.
    My requirement:
    1.i will be 2 sliders who choose (type varchar2) account number according to diff where clause.
    2. then, I need to compare these two cusrsor account number and fill out a folder or a collection, if the two account numbers are the same.

    This must be done using SQL. Not the tables or collections or associative arrays.

    SQL is the MOST powerful language, that you have in the Oracle RDBMS. It is faster than PL/SQL, when it comes to crunch data. It is more scalable.

    So why then pull data SQL in PL/SQL (expensive) memory? And then shoot some more SQL data in memory of PL/SQL (expensive)? And then use PL/SQL loop processing to compare the two sets of data?

    SQL can do that very quickly and very efficiently - as it was designed for this specific purpose.

    See the JOIN, INTERSECT , and LESS SQL operations to compare data sets.

  • join an associative array with table

    I'm new to associative arrays.

    Here, I'm doing the equivalent of as follows:
     create table mytable as select n1,padding from T1 where rownum <=5;
    Table created.
    And join this table with T1 and the corresponding records to get top 10
      1   SELECT * FROM
      2   (
      3     SELECT
      4              T1.n1
      5            , T1.small_vc
      6            , mytable.padding
      7      FROM
      8             mytable
      9            , T1
     10      WHERE
     11            mytable.n1 = T1.n1
     12   )
     13* WHERE ROWNUM <= 10;
    Now with the assicative bays
      1  DECLARE
      2          type array is table of T1%rowtype index by binary_integer;
      3          l_data array;
      4          l_rec T1%rowtype;
      5  BEGIN
      6          SELECT
      7                    *
      8          BULK COLLECT INTO
      9          l_data
     10          FROM T1
     11          WHERE ROWNUM <=5;   -- the top 5 records
     12          FOR i IN 1..l_data.count
     13          LOOP
     14                BEGIN
     15  --
     16               SELECT
     17                     *
     18               INTO
     19                     l_rec
     20               FROM
     21                     T1
     22               WHERE
     23                     T1.n1 = l_data(i).n1;
     24             EXCEPTION
     25               WHEN OTHERS THEN
     26                       DBMS_OUTPUT.PUT_LINE(to_char(SQLCODE) || ' - ' || substr(SQLERRM,1,200));
     27        END;
     28     END LOOP;
     29* END;
    [email protected]> /
    -1422 - ORA-01422: exact fetch returns more than requested number of rows
    -1422 - ORA-01422: exact fetch returns more than requested number of rows
    -1422 - ORA-01422: exact fetch returns more than requested number of rows
    -1422 - ORA-01422: exact fetch returns more than requested number of rows
    -1422 - ORA-01422: exact fetch returns more than requested number of rows
    Of course the encoding isn't fair. Also, I want to display the first 10 results set.

    Thank you

    Mich

    Talebzadeh mich wrote:

    Does it fast enough and I think it is necessary for using the pipeline to multiple joins functions to update the tables of FACTS so to speak.

    A pipeline returns data that are not indexed. So by default, using data from a pipeline function involves a full production table scan. That's why native SQL tables are better than a pipeline - as these are accessible and used optimally (via the index partitions, bitmaps, clusters, etc.).

    Since PTFS uses memory structures as associative arrays do, what are the main benefits of using TFP compared to the associative arrays in addition to the fact that in MFP memory structures are presented in the SQL format?

    Not the same structure. An associative array is typically a list linked and "indexed" differently.

    A normal array is accessible by compensation. Let's say it's an array of bytes 4 IEEE floats. 1st entry is at position 0 in the structure of memory. The 2nd entry at position 4. Etc.

    Index number of the table is used to determine the offset of this table cell in the structure of memory.

    An associative array is "indexed" using strings or dates or numbers (not sequential). Thus a structure like a linked list must be used. Access to the range means a search in this linked to the match index list and then read the value of this cell in the table.

    The associative arrays do exist in the SQL engine. It is a unique data structure of PL/SQL engine.

    As to the benefits of a pipeline - this is when the data must be processed and plain vanilla SQL is not able to do this and PL/SQL is required.

    Simple example. A flat web service XML data structure. A table of pipeline can use UTL_HTTP to make the service web call, retrieve the XML code and that the output data as rows and columns - in effect turning a web service interface into something that looks like a SQL table and can be used as if it were a table SQL.

    Reading Tom on the use of pipelines comments:
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:2814739467100916:P11_QUESTION_ID:19481671347143

    Also when can I use associative arrays functions insteard table in pipeline?

    Associative arrays are useful for the only PL/SQL data. For example, which deals with the pair name / value that are placed by a customer and that are used to determine which query or process data. For the majority of the PL/SQL code and the treatment, associative arrays are not necessary. And often wrongly used that developers do not seem to understand what an associative array is and how it differs from a normal table structure.

Maybe you are looking for

  • What happened to the button "go to the next unread?

    I've updated to disappeared you bird, 38.0.1, the button "go to the next unread". It's the key that used to be visible when you read a message in the upper right of the pane header, next to the button "reply to the sender of this message. In the late

  • Vista DEP ends the process of upgrade of Sony Picture Motion Browser (PMB)

    I have a problem with Windows Vista Home Premium.  I am trying to upgrade my version of Sony Picture Motion Browser (PMB) to version 5.2 running the updated DownloadManager_1005c.exe utility, which was downloaded from the Sony website.  When I run th

  • COM3 showing in Device Manager but not in the list of printer port

    I have a Datamax Allegoro printer that uses a USB series converter. The poster converter as installed correctly (in devices and Device Manager) and received COM3. When I go to change the player of the printer to use the COM3 port, it is not in the li

  • Hierarchy Viewer - settings

    I created a hierarchy Viewer to present the family relationship, as the family tree, and I can watch with all the parameters at first, but after that it shows me only one node, instead of the tree of all, Parent - profile search - Childs.How can I fi

  • Change the default e-mail - FAQ does not help

    I can't change my email address by default for the Community Site.  The FAQ is obsolete.  He referred to the former site of the community, not the new one version about a month ago.Change your E-mail addressThis page no longer applies.  The email is