Associative arrays... items in the index

I can control the index of an associative array like that...
 TYPE aat_id IS TABLE OF PLS_INTEGER INDEX BY PLS_INTEGER;
  aa_ids aat_id;

BEGIN

     aa_ids(1) := 3;
     aa_ids(2) := 8;
     aa_ids(2) := 10;
     
aa_ids.delete(2);

dbms_output.put_line(aa_ids.count);

END;
How can I control the index in the statement of collection in bulk as follows... so that I can delete records using this index
 SELECT decode(mod(rownum,2),1,1,2), object_name BULK COLLECT INTO aa_recs
     FROM   all_objects WHERE  ROWNUM <= 6;
Thank you
HESH.

HESH wrote:

but I have to play with the collected values, I want to delete the values in bulk without a loop through the list there at - it a trick possible to do this?

Using not PL/SQL and bays of PL/SQL at all - just using simple native SQL.

Before bulk collection and construction of an associative array, for the use of the values in table for future SQL operations, I rather to store the collection of values in a TWG (global temporary table) instead. A TWG can be indexed - and can thus provide much better access to the data as an associative array. He played better. It can be used via SQL, native mode.

The best place for the data is in the database. Not in the PL/SQL layer. This means that in SQL tables and not in PL/SQL tables or collections.

There are very few situations in PL/SQL, which require the use of associative arrays. If few, the majority of the PL/SQL code using associative arrays, IMO do badly. And what you've posted so far, I do not see a specific requirement for associative arrays.

So be sure you use the correct feature - and make sure that it is also well put to use in your code.

PS. HESH is a strange name. I'm used to HESH meaning High Explosive Squash Head (used for the filming of shielding). :-)

Tags: Database

Similar Questions

  • InDesign - how to re-enable the button "create a new item of the Index.

    When I was creating topics for my index finger, I saved the document after doing a subject - (because I had created topics yesterday and is not saved and lost all of my work) - when I tried to create a new item of the Index, the button wasn't dark - not active, so I was not able to add more topics to my Index. I rebooted my MacBook Pro (Mac OS X Version 10.6.8) and reopened my InDesign (Version 3.0.1) document and the palette Index box still lacks a button "Create a new item of the Index" assets to allow the action. I do not know how to do this - does anyone have any suggestions?

    I worked on the range of the Index of reference - adding items to the Index with a subject that I had already entered and when I went back to fashion topic, I noticed that the 'Create a new item of the Index' button is enabled - so I think everything is good now. Thanks for the forum.

  • The associative arrays, insert, rownum as index loop or not.

    Hi guys,.
    I want to keep this subset of rows around 5000 in a collection / table temporary but don't know how to do it. have not found much on google either.
    the associative array seems good because it has no limit (and it may be more than 5000) and it offers a quick access.

    DECLARE
    TYPE assoc_array_str_type IS TABLE OF VARCHAR2 (32) INDEX OF PLS_INTEGER;
    assoc_array_str_type v1.
    BEGIN

    (23231) v1: = 10;

    -Select distinct rownum, rmnumber made in v1.

    END;

    I thought that I have use rownum as index but have the feeling that I can't 'load' a set of data both in the associative array. I need to loop and then add one don't I? is there a faster way?

    You can use in bulk to collect:

    declare
       type assoc_array_str_type is table of varchar2(32) index by pls_integer;
       v1 assoc_array_str_type;
    begin
       select ename
       bulk collect into  v1
       from   emp;
    
       dbms_output.put_line('v1(1)='||v1(1));
       dbms_output.put_line('v1(2)='||v1(2));
    end;
    /
    v1(1)=KING
    v1(2)=BLAKE
    
  • How to get the item to the index by the listview in qml programming

    Hi guys.

    I'm sorry my English not good level.

    At the point of selection Android listview to index easylly, I call ListView.selectionPosition (int index)

    But when you use ListView on cascades qml, I think point get in way to the index.

    Hope you help me.

    For a simple DataModel with a single level of items, you can access the item at a specific position with code of God:
    int position = 0
    var MonElement = myDataModel.data ([position])-requires one [of QVariantList]

  • 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).

  • 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

  • INDD 6.0.6 give up when I try to delete the reference in the index

    See also http://forums.Adobe.com/message/4263687 for a discussion of the same problem. Ask here, I'm starting a discussion separate from the same issue affecting someone else (me).

    I am running INDD 6.0.6 on OS X 10.6.8 on a MacBook Pro (2.53 GHz Intel Core 2 Duo). I have a document. INDD that is part of a 50-page book. The document includes an index. The index was imported originally from MS Word (from another user, unknown version). I'm rewriting the index, editing and re-release strongly. I recently discovered that the index is a reference without a target. To be clear, I don't know of a reference in the text of the document. It is an index entry, created by new cross-reference... menu item in the Index pane. There is no target, because when you look at it with forwarding options, there is a first-level topic, but the referenced field (below the Type see also) is empty.

    I can't delete this entry. When I try to delete, INDD crashes. When INDD covers, he warns that the document is may be damaged, and if I try to delete it again, INDD breaks down. If I try to change the referenced field, INDD accepts but does not take into account the change (the closing of the shutter, but the remains of the unchanged index).

    My current solution is to change the theme to ZZZ and add a new index entry (ZZZ: corrupt entry: delete this before shipping), but it is less satisfactory. What can I do to remove the corrupted index cross-reference?

    The biggest problem is that even if you and someone from Adobe to be able to actually understand what that is the problem and that it is, in fact, a bug, there's nothing they can do to help you. There won't be any several bug fixes for CS4. My memory is that he had some bugs in indexing in the first version of CS4 and at least some of them are fixed, then you must install the patch...

  • 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.

  • 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.
    
  • 'Replace the element of the array' replaces not only indexed items

    Hey masters LabView,.

    Fairly new to Labview and I'm trying to sort out how to create a table of images. I know that the total number of images I want in my 'stamp' (not the buffer of LabView), so I'm the initialization of an array of this size. Can I bring this table in a loop For with a shift register, and I want to capture images and write them in the table of the buffe continuously (a comment: I do a circular buffer, but I don't want to implement in LabView, because there a lot of things that I don't need and I will eventually have to the process to be as thin as possible).

    Here's the problem (I assume an implementation, that does not decompose LabView):

    I expect:

    AN element of the array, in the position indicated by the index of the loop [i], is replaced by the image newly caught

    I get:

    All THE elements of the array becomes the image newly caught.

    (I can tell because I taste under the table, grabbing a single image from a constant "Check Array" index - may 7, for example.) But my index of the loop [i] value is 13, and the subsample becomes again the image newly caught.

    What a ridiculous thing I am doing wrong?

    Any help would be greatly appreciated.

    Ah, I just noticed something.  Initialize you an array of references at the beginning of your program, but it is a complete picture OF THE SAME REFERENCE: you must call the IMAQ Create in a loop so that you actually get unique references in your table.  You must have a different NAME for each image.

  • Implementation of associative array (indexes per Table) in the procedure

    Hi guys,.

    I'm trying to implement collections in the procedure. I am trying to store integer values as well as the names & to print the same list of names. Here is my procedure

    create or replace procedure (coll_proc)

    )

    is

    pay type is table of the index number to varchar2 (20);

    salary_list salary;

    L_Name varchar2 (2000);

    Start

    salary_list ('Aude'): = 62000.

    salary_list ("Mohammed"): = 50000;

    ("Julian") salary_list: = 45000;

    L_Name: = salary_list.first;

    l_name is not null loop

    dbms_output.put_line (' the wages of ' |) L_Name | « est » ||' ='|| TO_CHAR (salary_list (L_Name)));

    L_Name: = salary_list. Next (L_Name);

    end loop;

    end;

    Below is the error

    "Error (2.1): PLS-00103: encountered the symbol") "when expecting one of the following numbers: Remove current exists prior" "

    You people could please check this & tell me that where I'm going wrong.

    Hello

    It seems that you have all the parameters in your stored procedure, so remove the "()" after the name of the procedure.

    create or replace procedure coll_proc
    is
      type salary is table of number index by varchar2(20);
      salary_list salary;
      l_name varchar2(2000);
    begin
      salary_list('Rajnish'):=62000;
      salary_list('Minakshi'):=50000;
      salary_list('Seetha'):=45000;
    
      l_name:= salary_list.first;
      while l_name is not null loop
        dbms_output.put_line('Salary of ' ||l_name|| 'is'||'='|| to_char(salary_list(l_name)));
        l_name:=salary_list.next(l_name);
      end loop;
      end;
    

    I tried this and able to create the procedure

    Procedure created.
    

    Kind regards

    Jitendra

  • What is the maximum number of associative array indexes?

    I used

    number_type type is the number table
    index by pls_integer;
    number_array number_type;

    However. When I,

    number_array (2808000301): = 42;

    It gives the error of overflow because the index type is pls_integer, and when I change the type index number pls_integer it gives an error.

    My question is what can I do to prevent this?

    Polat says:
    But, I mean, I also want to know is there a solution without it?

    Thank you Mr President.

    I don't think that the other options are there...

    But it is unlikely that you will need a digital index as 2808000301.

    The tables are not intended to deal with the enormous amount of data...

  • get the index of an element of an array with the click of mouse

    Hi all

    I want to get the index of an item in an array when I click on that element. I have seen a few examples in the forum, but they do not work for me... Can someone please help me to do this. I enclose my vi here.

    Thanking you with impatience,

    Kind regards

    Nitz...


  • What is the preferred means of data transmission as a type of record between the nested table of pl/sql program or an associative array

    What is the preferred means of data transmission in the associative array of the nested table record vs

    Choose between Nested Tables and associative arrays

    The two nested tables and associative arrays (formerly index - by tables) use similar index notation, but they have different characteristics when it comes to persistence and ease of passing parameters.

    Nested tables can be stored in a column of data, but can of associative arrays. Nested tables can simplify the SQL operations where you would normally join a single-column table with a larger table.

    Associative arrays are appropriate for relatively small lookup tables where the collection can be constructed in memory whenever a procedure is called or a package is initialized. They are good for the collection of the information volume is unknown beforehand, because there is no fixed limit on their size. Their index values are more flexible, as associative array indices can be negative, can be no sequential and can use values of string instead of numbers.

    PL/SQL automatically converts between the bays of the host and the associative arrays that use values of digital keys. The most effective way to move the collections to and from the database server is to implement data values in associative arrays, and then use these associative arrays with erections in bulk (the FORALL statement or BULK COLLECT clause).

    With the help of documents and Collections of PL/SQL

    Read this:

    How to pass the record set as a parameter of the procedure.

    https://community.Oracle.com/thread/2375173?TSTART=0

Maybe you are looking for

  • Satellite X 200 - 23 G - need the drivers for Windows 7

    Hello buddy! In the first place, I am Brazilian and I have some difficulties to speak in French.Let's go to the problem: I had installed Windows 7 Ultimate here in my Satellite X 200-23 g (PSPBUE), but I'm not finding some drivers. Drivers: video car

  • XPS controller

    Hello I'm using LabView to program the controller XPS of Newport. This instrument has accompanied LabView drivers of Newport. For the moment, I'm just trying to learn how to control a single-axis group, IE. a step only. I am able to make the scene re

  • By current wireless extension line? WAP54G or something better?

    I have a WRT54G Router and I also use equipment Linksys powerline (PLE300 and PLS300 units).  Cpl equipment works fine.  We have cable modem and through a connection wired router or connection powerline ethernet, I get 20 download speeds to 25 Mbit/s

  • Model Z60t 2511 enhanced 100 GB to 160 GB - does not start!

    I always used (successfully) Casper to clone hard drives for replacement. I'm now replace a 100 GB with a 160 GB, but I fell... What exact steps do I need to clone the hard disk of this model from 100 GB to 160 GB Hitachi HTS542516K9SA00 (5K 250-160)

  • Preinstalled windows 8 so no cd - how can I get the cd

    I have a samsung laptop that came with a preinstalled windows copy 8 However when I installed ubuntu a while ago things I screwed up, and I could not load in windows 8, or ubuntu. In the end, I had to start my laptop with a windows 7 cd. But I want n