Re: creating dynamic associative arrays

Hi, I need some advice on the following problem. I develop code that allows me to copy & paste a spreadsheet into a TextArea and parse text pasted to dynamically generate a DataGrid control. I assume that the first line of text contains the headers of each column, parse the line and dynamically generate the columns to the DataGrid control. Now I need a way to generate each Clotilde the DataGrid from the rest of the lines. The question that I'm struggling with (new Flex) is. I think I need to create an associative array of the form:

var asArray:Object = {col1: 'value1', col2: "Value2", etc.}

The problem is that all the column names in a table and each value is stored in another table. How to dynamically create a construction which will be

take me to represent a row in a DataGrid as described in EnTableau? In other words, is there a way to dynamically generate a statement like the one above?

Grateful for your help!

Ko

If I understand correctly, you are able to analyze all your data to two types of arrays:

var table: columns = {"column1", "column2",...}

var rowValues:Array = {, ",...}

So as you can see I guess that each value in rowValues table has light-emitting column name in the columns table. So you can build your 'associative' (in fact it is just a simple object) like this:

var rowObject:Object = new Object();

for (var i: int = 0; i< rowvalues.length;="" i++)="">

rowObject [GBA [i]] = rowValues [i];

}

The heart of the loop is the third line and the use of hooks on an object.

Tags: Flex

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.

  • Associative array as a type of database

    As it is very well create an associative array inside a stored procedure:

      type urltype  is table of varchar2(32767) index by varchar2(30);
    
    

    Can it be created as a type of database at the level of the schema?

    Brian.McGinity wrote:

    As it is very well create an associative array inside a stored procedure:

    1. type urltype is the table of index varchar2 (32767) by varchar2 (30);

    Can it be created as a type of database at the level of the schema?

    Non - associative arrays are a function of PL/SQL.

    See table 5-1 in the doc of the PL/SQL language for a description of each type of collection and where (pl/sql, sql, etc.) they can be used.

    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/composites.htm#CHDBHJEI

  • 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

  • PLS-00201 when adressing field in an associative array

    To calculate the scores, I created an associative array that contains the totals of players until last week.

    In a loop, I can make each player and add their scores this week to their total of last week.

    Code:

    Associative array:
    italics
    create or replace
    TYPE "NUMBER_ARRAY" in the table of the number;

    cur_vorige_totalen_array number_array;

    FOR r_vorige_totalen in c_vorige_totalen (ld_training_dag)
    LOOP
    cur_vorige_totalen_array.extend;
    cur_vorige_totalen_array (r_vorige_totalen.lidnummer): = r_vorige_totalen.totaal_punten_dit_seizoen;
    END LOOP;
    italics

    To add the total to the current scores can do:
    italics
    OPEN c_huidige_totalen.
    LOOP
    Get the c_huidige_totalen COLLECT LOOSE cur_totalen_array LIMIT 100;
    EXIT WHEN c_huidige_totalen % NOTFOUND;
    END LOOP;
    CLOSE C_huidige_totalen;

    FORALL i IN cur_totalen_array. FIRST... cur_totalen_array. LAST
    Training_aanwezigheid UPDATE your
    SET ta.totaal_punten_dit_seizoen TREAT (cur_totalen_array (i) AS huidige_totalen_type) = .totaal_punten_dit_seizoen + cur_vorige_totalen_array (ta.lidnummer)
    WHERE ta.lidnummer = TREAT (cur_totalen_array (i) AS huidige_totalen_type) .lidnummer
    AND ta.training_id = p_training_id;
    italics

    I get an error PLS-00201 (ta.lidnummer must be set) on "BOLD" cur_vorige_totalen_array (ta.lidnummer) "BOLD"

    Is it not possible to address ta.lidnummer in this way? How can I solve my problem in this case?

    TX for your advicec

    Hello

    Discover FORALL statement Chater:
    http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14261/forall_statement.htm#i34324
    Your code is not to comply with these restrictions:
    >
    -Part of a loop FORALL, impossible to make reference to the collection even in both the SET clause and the WHERE clause of an UPDATE statement. You need to maybe make a second copy of the collection and the new name in the WHERE clause.
    -Impossible to refer to the individual record fields in the DML statements called by a FORALL statement. Instead, you can specify the entire file with the ROW SET clause in an UPDATE statement, or the VALUES clause in an INSERT statement.
    -Indexes collection should be just the index rather than an expression variable, such that I rather than I + 1.
    >
    The last restriction is because you use this:
    FORALL i IN cur_totalen_array. FIRST... cur_totalen_array. LAST
    Training_aanwezigheid UPDATE your
    SET ta.totaal_punten_dit_seizoen = TREAT (cur_totalen_array (i) AS huidige_totalen_type) .totaal_punten_dit_seizoen
    + cur_vorige_totalen_array ( ta.lidnummer )

    Single index variable is allowed as a clue - you cannot use variable I have here.

    Published by: kordirko on 2010-10-20 23:38

  • Associative array syntax

    I want to create an associative array, but using variables instead of coding hard.

    example of

    Instead of

    Assoc ['field1'] = data;

    I want to

    Assoc [fieldname] = data;

    I read for centuries and can't seem to find anything. I tried the above and it does not work.

    Any suggestions?

    Okay, I think that I managed to solve it. It seems to work although I don't know if maybe I've not initialized properly. I had a number of things wrong with the previous code. One was to have the push in the loop of passes and the other has changed the way to configure the array.

  • How to create dynamic arrays parallel/side-by-side in Adobe cycle

    Is it possible to create dynamic arrays parallel/side-by-side in Adobe cycle?  If so, how?

    Given that the tables have different sizes, in that I am running wrapping issues with running adjustment of Western characters and characters from the pagination with checkpoint.  Any other ideas?

    In fact, I had tried this solution ("wrapping the tables in a subform of position and set to automatically adjust the height and allow page breaks"), but it did not work.  Something to do with nested subforms of position within a subform control flow etc.  So to make it work, I set the page to be a subform of position and the auto-hauteur value and allow page breaks and I unpacked the paintings while they were only 'wrapped up' of the page itself.

  • Associative array

    I have a table proj_test .i want to recover the data in the associative array.

    How to do?

    create table proj_test as  
      select 1 as id, 1 as rn, 'Fred' as nm from dual union all  
      select 1,2,'Bloggs' from dual union all  
      select 2,1,'Scott' from dual union all  
      select 2,2,'Smith' from dual union all  
      select 3,1,'Jim' from dual union all  
      select 3,2,'Jones' from dual  
    
    

    You need not Associative array if you do a bulk of collect. You can use the nested PL/SQL table type.

    11g and more

    declare

    is of type tbl table of the proj_test % rowtype;

    tbl l_tbl;

    Start

    SELECT id, rn, nm bulk collect into l_tbl

    of proj_test;

    because me in 1.l_tbl.count

    loop

    dbms_output.put_line

    (

    RPAD (to_char (l_tbl (i) USER.USER), 10, ' ')

    || RPAD (to_char (l_tbl (i). (RN), 10, ' ')

    || l_tbl (i) .nm

    );

    end loop;

    end;

    Before 11 g

    declare

    type id_tbl is table of the proj_test.id%type;

    type rn_tbl is table of the proj_test.rn%type;

    type nm_tbl is table of the proj_test.nm%type;

    id_tbl l_id;

    l_rn rn_tbl;

    l_nm nm_tbl;

    Start

    SELECT id, rn, nm bulk collect into l_id, l_rn, l_nm

    of proj_test;

    because me in 1.l_id.count

    loop

    dbms_output.put_line

    (

    RPAD (to_char (l_id (i)), 10, ' ')

    || RPAD (to_char (l_rn (i)), 10, ' ')

    || l_nm (i)

    );

    end loop;

    end;

  • Error renaming dates to an associative array of type date

    Hi all

    I am facing issue while assigning dates in an associative array of type date:

    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
    AMT for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production

    Stored procedure, I try to write is as follows

    1. create or replace procedure (jp1)
    2. p_start_date default date trunc(sysdate,'MM')
    3. p_end_date date default trunc (sysdate)
    4. )
    5. is
    6. number of l_no_of_days;
    7. type t_date_id is table of date
    8. index by pls_integer;
    9. l_date_id_arr t_date_id;
    10. Start
    11. l_no_of_days: = p_end_date - p_start_date;
    12. for i from 0
    13. .. l_no_of_days - 1
    14. loop
    15. l_date_id_arr: = p_start_date + i;
    16. dbms_output.put_line (p_start_date + i);
    17. end loop;
    18. end;
    19. /

    I get error on line 14 when compiling it. and the error message is as follows:

    JP1 PROCEDURAL errors:

    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    14/5 PL/SQL: statement ignored
    14/22 PLS-00382: expression is of the wrong type

    While studying this, I tried the value of (p_start_date + i) using dbms_output.put_line and the output is so date itself.

    1. create or replace procedure (jp1)
    2. p_start_date default date trunc(sysdate,'MM')
    3. p_end_date date default trunc (sysdate)
    4. )
    5. is
    6. number of l_no_of_days;
    7. type t_date_id is table of date
    8. index by pls_integer;
    9. l_date_id_arr t_date_id;
    10. Start
    11. l_no_of_days: = p_end_date - p_start_date;
    12. for i from 0... l_no_of_days-1

    13. loop
    14. -l_date_id_arr: = p_start_date + i;
    15. dbms_output.put_line (p_start_date + i);
    16. end loop;
    17. end;
    18. /

    output of the

    1. exec jp1

    is as follows:

    1ST DECEMBER 13

    2 DECEMBER 13

    3 DECEMBER 13

    DECEMBER 4, 13

    5 DECEMBER 13

    DECEMBER 6, 13

    7 DECEMBER 13

    DECEMBER 8, 13

    9 DECEMBER 13

    DECEMBER 10, 13

    DECEMBER 11, 13

    DECEMBER 12, 13

    13 DECEMBER 13

    14 DECEMBER 13

    15 DECEMBER 13

    16 DECEMBER 13

    17 DECEMBER 13

    18 DECEMBER 13

    I see the release date itself. so why he throws error while the same assignment to an associative array of type date.

    I tried Google too for the same but without success.

    Any help is appreciated in this regard not or any pointer another thread on the internet or in this forum.

    Thanks in advance

    Jagdeep Seven

    Read associative arrays:

    1. create or replace procedure (jp1)
    2. p_start_date default date trunc(sysdate,'MM')
    3. p_end_date date default trunc (sysdate)
    4. ) is
    5. number of l_no_of_days;
    6. type t_date_id is table of date
    7. index by pls_integer;
    8. l_date_id_arr t_date_id;
    9. Start
    10. l_no_of_days: = p_end_date - p_start_date;
    11. because me in 0.l_no_of_days - 1
    12. loop
    13. l_date_id_arr (I): = p_start_date + i;
    14. dbms_output.put_line (p_start_date + i);
    15. end loop;
    16. end;

    ----

    Ramin Hashimzade

  • Associative array of index files by varchar2 - PLS 00382

    I have a SQL anonymous block that creates a report. At the end of each section, I need to summarize the data by "renting". The list of locations is finished (approx. 15 in a table) and not all sections will have data for each location, but I want the locations to order the same so I thought I'd use an associative array to store summary data. But when I try to initialize the associative array (I simply put the slots in the array in the "correct" order) I receive PLS-00382 expression is of the wrong type.

    Here is the code (the lines where the error occurs are in bold):

    TYPE summary_data () IS RENDERING
    Summary1 NUMBER,
    NUMBER of summary2
    NUMBER of summary3
    );

    Summ_arr TYPE IS TABLE of summary_data INDEX OF VARCHAR2 (5);

    location_summary summ_arr;

    aLoc VARCHAR2 (5);

    PROCEDURE init_summ (aSummArr IN OUT summ_arr) IS
    BEGIN
    aSummArr.Delete;

    BEGIN
    FOR in aLoc (select name - name is VARCHAR2 (5))
    table
    control key)
    LOOP
    aSummArr (aLoc) .summary_1: = 0;
    aSummArr (aLoc) .summary_2: = 0;
    aSummArr (aLoc) .summary_3: = 0;
    END LOOP;
    EXCEPTION
    -exception handling
    END;

    END;

    If this is not allowed, or I do something wrong? I tried substituting:

    Summ_arr TYPE IS TABLE of summary_data INDEX OF VARCHAR2 (5);

    with

    Summ_arr TYPE IS TABLE of summary_data INDEX table.key%TYPE;

    Nothing helps.

    Thanks in advance for your help with this.

    ANNUAL GENERAL MEETING

    ALOC is a record variable. You need to refrence the column in the file said. So, something like this:

    aSummArr(aLoc.name).summary_1 := 0;
    

    Cheers, APC

  • Associative arrays

    Quoting docs.oracle.com lines


    Associative arrays are used to represent sets of data of arbitrary size, with quick search of an individual element without its position in the table and without
    having to loop through all the elements in the array. Here is a small example

    DECLARE
    TYPE population_type IS TABLE OF NUMBER INDEX OF VARCHAR2 (64);
    country_population population_type;
    continent_population population_type;
    howmany NUMBER;
    that VARCHAR2 (64);
    BEGIN
    country_population ('Greenland'): = 100000; -Creates the entry
    country_population ('Iceland'): = 750000; -Creates the entry
    -Research associated with a value chain
    howmany: = country_population ('Greenland');
    continent_population ('Australia'): = 30000000;
    continent_population ('Antarctica'): = 1000; -Creates the entry
    continent_population ('Antarctica'): = 1001; -Replaces the previous value
    -Returns "Antarctic" which comes first in alphabetical order.
    who: = continent_population. FIRST;
    -Returns "Australia", which comes last in the alphabetical order.
    who: = continent_population. LAST;
    -Returns the value corresponding to the last key, in this
    -case of the Australia population.
    howmany: = continent_population (continent_population. LAST);
    END;
    /



    my doubt is in what regards the statement "with a quick search of an individual element without its position in the table".can someone give a small relevant example. Therefore the associative arrays is also appropriate for relatively small lookup tables where the collection can be constructed in memory eachtime, a procedure is called? Thanks in advance...

    >
    my doubt is in what regards the statement "with a quick search of an individual element without its position in the table".can someone give a small relevant example.
    >
    Think of it as gradually close equivalent to a hash of key/value pairs. When you want to insert an item provide you the key, Oracle axe key to find the entry in the hash table. It doesn't matter if the entry is the first, last, or any other arbitrary position in the table.
    >
    Therefore the associative arrays is also appropriate for relatively small lookup tables where the collection can be constructed in memory eachtime, a procedure is called?
    >
    The scope of the variables of the procedure is only the duration of the procedure. They are built when the procedure is called and destroyed when the procedure ends.

    If any associative array created in the procedure must be small to minimize the impact on the performance of the table fill. If the procedure performs complex calculations or ETL one record at a time, it is more efficient to get a value from the array instead of having to re - query a database table for him.

    For example, for the United States, a list of 50 State and their full name abbreviations that can be stored in an associative array and procedure could extract the code of the State of a data element, and quickly find the name of the State of the table. It would be faster than executing a query on the database on a lookup table.

  • Associative array in Oracle procedure problem

    Hello

    I searched through the internet and this forum and have not been able to solve a problem using the associative array of values in an IN clause. Everything I read says that I can not use the associative array directly in the SQL statement. I have to convert it to a table and then I can use it. Unfortunately, I get a ' ORA-21700: object does not exist or is marked for deletion "error when trying to access the table, I filled the table. Please note that I checked the table is actually filled during the loop. I capture the error when you are referencing in the SELECT statement.

    I stated the following in the ARCHIVE package specification:

    TYPE RSType IS REF CURSOR;
    TYPE integer_aat IS TABLE OF INTEGER INDEX BY PLS_INTEGER;
    Integer_table TYPE TABLE IS OF INTEGER;


    The procedure is the following:

    PROCEDURE SEL_SEARCH_RESULTS (v_term IN VARCHAR2,
    v_categories IN ARCHIVE.integer_aat,
    RS ON RSType)
    AS
    / * END: Returns the results for the category and key word provided
    VARIABLES:
    v_categories = array of categories of documents
    v_term = keyword entered
    RS = game results
    */
    tbl_cat ARCHIVE.integer_table: = ARCHIVE.integer_table ();

    BEGIN

    BECAUSE me in 1... v_categories. COUNTY
    LOOP
    tbl_cat. EXTEND (1);
    tbl_cat (i): = v_categories (i);
    END LOOP;

    OPEN FOR RS
    SELECT A.ID,
    B.CATEGORY,
    A.FILENAME,
    A.DISPLAY_NAME,
    A.COMMENTS
    OF TBL_ARCHIVE_DOCUMENTS,.
    B TBL_ARCHIVE_DOC_CAT,
    C TBL_ARCHIVE_DOC_KEYWORDS
    WHERE A.ID = B.ID
    AND A.ID = C.ID
    AND B.CATEGORY in (SELECT * FROM TABLE (tbl_cat))
    AND C.KEYWORD = v_term
    ORDER BY A.ID;
    END SEL_SEARCH_RESULTS;

    Any help would be greatly appreciated and thanks in advance.

    Matt

    905707 wrote:
    Thanks for the quick response. I looked at the example suggest you and made the following changes. Now, I get an invalid 'Data Type' error on the "column_value SELECT FROM TABLE (CAST (tbl_cat AS tbl_integer))' statement. I must be missing something simple and I can't put my finger on it.

    You did not create a SQL type as I said. tbl_integer is still declared in the PLSQL code you have posted.

    Reread my initial response and look at the example I posted (the very first thing that is done is to create a SQL type).

  • 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>
    
  • An associative array in PL/SQL: key = varchar2, value = varray (varchar2)

    I'm doing an associative array, where the key is a string and the value is an array of strings.

    I tried to declare it like this:

    PROCEDURE myProcedure IS
    tableau_donnees argument type is varray (200) of VARCHAR2 (20);
    Column TYPE IS an ARRAY OF tableau_donnees INDEX BY VARCHAR2 (20);
    my_collection columns; -collection of multi dimensional pl/sql
    BEGIN
    my_collection ('test') (1): = "Hello"; -It is the idea...
    "my_collection ('test') (2): = ' 8128 is the number";
    my_collection ("some other field' ') (1): = 'foo';
    -etc etc.

    But I get the error Oracle ORA-06531, reference to an uninitialized collection:

    Cause: A service of element or member of a nested table or varray has been referenced (where an initialized collection is necessary) without the collection has been initialized.

    Action: Initialize the collection with an appropriate constructor or assignment of the whole object.

    I tried to use 'extend()' initialize the varray, but no help...
    my_collection('test').extend (200);

    -----
    I also tried this:

    PROCEDURE myProcedure IS
    Data TYPE of TABLE IS OF VARCHAR2 (20);
    Column TYPE IS an ARRAY OF data INDEX BY VARCHAR2 (20);
    my_collection columns; -collection of multi dimensional pl/sql


    But it's always the same. I am quite new to PL/SQL, if any help would be great!


    -j

    900685 wrote:
    I'm doing an associative array, where the key is a string and the value is an array of strings.

    create or replace
      procedure myProcedure
        is
            type data_array
              is
                varray(200) of varchar2(20);
            type coltype
              is
                table of data_array
                index by varchar2(20);
            my_collection coltype;
        begin
            my_collection('test') := data_array('hello','8128 is the number');
            my_collection('some other field') := data_array('foo');
    end;
    /
    

    And if you want to add elements in varray:

    create or replace
      procedure myProcedure
        is
            type data_array
              is
                varray(200) of varchar2(20);
            type coltype
              is
                table of data_array
                index by varchar2(20);
            my_collection coltype;
        begin
            my_collection('test') := data_array('hello');
            my_collection('test').extend;
            my_collection('test')(2) := '8128 is the number';
            my_collection('some other field') := data_array('foo');
    end;
    /
    

    Or:

    create or replace
      procedure myProcedure
        is
            type data_array
              is
                varray(200) of varchar2(20);
            type coltype
              is
                table of data_array
                index by varchar2(20);
            my_collection coltype;
        begin
            my_collection('test') := data_array(); -- initialize
            my_collection('test').extend;
            my_collection('test')(1) := 'hello';
            my_collection('test').extend;
            my_collection('test')(2) := '8128 is the number';
            my_collection('some other field') := data_array('foo');
    end;
    /
    

    SY.

  • 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

  • Anyone else want to get rid of the words "Press to open" on the new lock screen?

    Is there a way to get rid of the words, "Press to open" on the new lock in iOS10 screen? I really don't need to be reminded every time how to unlock my phone, not to mention that I think that they look ugly.

  • [S1670CDS] Updates for ACPI and Overclocking

    Hello First of all, let me tell you how happy I am having found such a community; (O) I used to participate in the "Toshiba Linux users' mailing list, but never had advice windows on it. I own a 1670 CD Satellite, which belongs to the ' 1670 CD / 169

  • Satellite L735 - 10 M - I can't install Bluetooth

    Hello I reinstalled my computer toshiba laptop with W7 HP SP1 SK, allows to activate my OEM product key, and then install the drivers then apps, but BT is not installed, why? * BIOS * v.: 2.50 (in bios have any bluetooth options)* OS: * Windows 7 Hom

  • Where are the videos recently added (new Apple TV, 64 GB)

    I mainly use my Apple TV to the floor to show my videos from my media server.  I add about 3 videos per week that I use to show my students.  On the old Apple TV, if you browse the 'computer', when you back out to the main screen, you can see recentl

  • Setup.exe has stopped working

    Hello, I am trying to install a driver for a "Turtle beach II Micro" usb sound card. Whenever I try to open the .exe file, I get the following: Setup.exe has stopped working A problem caused the blocking of the program works correctly. Windows will c