Use an associative array with the paragraph

Hello
I'm trying to do something like this:

declare
l_items parse_pkg.items_tt;
Enter numbers are the number table.
n numbers;
org varchar2 (100): = 1 | 2. 3. 4';
Start
l_items: = string_to_list (org); -string_to_list is Steve Feuerstein function that returns a table of varchar2s, items_tt
Select to bulk org fired n of org_table
where org table (l_items);
end;

This seems like it should work when I look at http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:210612357425
I'm sure that someone understands what I'm trying to do and can point me to the light.
Thank you!

user12020272 wrote:
Thanks much for the reply. I'm trying to understand your first point.

All my 'points' are for the second part, which executes the SQL statement. I'll give you a simplified example:

SQL> declare
  2      type items_tt is table of varchar2(10);
  3      l_items items_tt := items_tt('KING','ALLEN');
  4      type numbers is table of number;
  5      n numbers;
  6  begin
  7      select  sal
  8        bulk collect
  9        into n
 10        from emp
 11        where ename in l_items;
 12  end;
 13  /
      where ename in l_items;
                     *
ERROR at line 11:
ORA-06550: line 11, column 22:
PLS-00642: local collection types not allowed in SQL statements

SQL> 

Now create type items_tt in SQL:

SQL> declare
  2      l_items items_tt := items_tt('KING','ALLEN');
  3      type numbers is table of number;
  4      n numbers;
  5  begin
  6      select  sal
  7        bulk collect
  8        into n
  9        from emp
 10        where ename in l_items;
 11  end;
 12  /
      where ename in l_items;
                     *
ERROR at line 10:
ORA-06550: line 10, column 22:
PL/SQL: ORA-00932: inconsistent datatypes: expected NUMBER got SCOTT.ITEMS_TT
ORA-06550: line 6, column 5:
PL/SQL: SQL Statement ignored

SQL> 

So, we went first issue. Now my second point:

SQL> declare
  2      l_items items_tt := items_tt('KING','ALLEN');
  3      type numbers is table of number;
  4      n numbers;
  5  begin
  6      select  sal
  7        bulk collect
  8        into n
  9        from emp
 10        where ename member of l_items;
 11  end;
 12  /

PL/SQL procedure successfully completed.

SQL> 

As I already mentioned, this also works:

SQL> declare
  2      l_items items_tt := items_tt('KING','ALLEN');
  3      type numbers is table of number;
  4      n numbers;
  5  begin
  6      select  sal
  7        bulk collect
  8        into n
  9        from emp
 10        where ename in (select * from table(l_items));
 11  end;
 12  /

PL/SQL procedure successfully completed.

SQL> 

SY.

Tags: Database

Similar Questions

  • the associative arrays containing the record type, cannot be used first

    I am having trouble with the declaration of an associative array containing the Types of records and iteration using FIRST and NEXT functions.
    This problem of mine is only appear when I use that types of records, the FIRST and FOLLOWING operators work very well when you use the regular NUMBER.

    Trying to get the first element of the array, I get: ORA-06550: line 22, column 40: PLS 00382: expression is of the wrong type

    See the code snippet below. Anyone know if this can be done in PL/SQL?

    -----------------------------------------------------------------------------------------
    DECLARE


    -Set the record structure that will contain information on a post
    TYPE PostRec IS (RECORD
    post_type VARCHAR2 (4) - maybe DEB/CRED
    );

    lr_charge_back_post PostRec;

    TYPE post_table IS TABLE OF PostRec NOT NULL
    INDEX BY VARCHAR2 (4);

    assoc_posts post_table;

    BEGIN


    -lr_charge_back_post.post_type: = "asd";
    assoc_posts('1').post_type: = '1';

    lr_charge_back_post: = assoc_posts.first;

    END;
    /

    Returns the index, not the file FIRST:

    SQL> declare
      2  TYPE PostRec IS RECORD (
      3  post_type VARCHAR2(4) -- Can be DEB/CRED
      4  );
      5
      6  lr_charge_back_post  varchar2(20);
      7  TYPE post_table IS TABLE OF PostRec NOT NULL
      8  INDEX BY VARCHAR2(4);
      9
     10
     11  assoc_posts post_table;
     12
     13  BEGIN
     14
     15
     16  --lr_charge_back_post.post_type := 'asd';
     17  assoc_posts('1').post_type := '1';
     18
     19  lr_charge_back_post := assoc_posts.first;
     20  dbms_output.put_line('idx='||lr_charge_back_post);
     21  END;
     22  /
    idx=1
    
    PL/SQL procedure successfully completed.
    
    SQL> declare
      2  TYPE PostRec IS RECORD (
      3  post_type VARCHAR2(4) -- Can be DEB/CRED
      4  );
      5
      6  lr_charge_back_post  varchar2(20);
      7  TYPE post_table IS TABLE OF PostRec NOT NULL
      8  INDEX BY VARCHAR2(4);
      9
     10
     11  assoc_posts post_table;
     12
     13  BEGIN
     14
     15
     16  --lr_charge_back_post.post_type := 'asd';
     17  assoc_posts('idx').post_type := '1';
     18  lr_charge_back_post := assoc_posts.first;
     19  dbms_output.put_line('idx='||lr_charge_back_post);
     20  END;
     21  /
    idx=idx
    
    PL/SQL procedure successfully completed.
    

    Max
    http://oracleitalia.WordPress.com

  • 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

  • Fill an input array with the values from the worksheet

    Is it possible to fill an input array with the values to a text file or a spreadsheet? If so, how do you?

    Thanks to GerdW and all who responded. Fill a table control using a local variable with "The spreadsheet file read" as he entered works perfectly.

  • Array with the element in Type String

    Hi all

    It seems that I couldn't create an array with the element in the string Type, all that available to choose is double or decimial.

    I'm sure it's my fault because I'm fresh for her.

    Any idea is appreciated,

    + Kunsheng

    You should be able to use array initialize with data type to string, see below:

  • Find/replace, searching for specific text to replace it with the paragraph tag

    I tried to replace a string of text that I have at the beginning of a paragraph indicating a certain style of paragraph with this style of ID while eliminating the text string. For example, I put @IN1 at the beginning of a paragraph I want formatted with the paragraph of my ID IN1 style. However, when I have 'Search' @IN1 with no. find format and 'to' do not change (i.e. empty) with the paragraph style selected 1 selected under format change, it applies the paragraph style, but does not delete the text string @IN1. When you do a search/replace without the portion of paragraph desired syle, he removes the @IN1 correctly. It is a bug, or is there something I have to put in the change of area indicate no text? Thank you

    Using the GREP tab, find ^ (@IN1) (.) and replace with $2 and set the paragraph style in the change of format.

    The ^ beginning of paragraph says and the $2 is the second subexpression matching.

  • Can I use an SD card with the new MacBook?

    Looking to buy a new MacBook. From what I can tell there is no SD card reader.  I don't see any accessory adapter for SD readers either.  Is it possible to use an SD card with the new MacBook?  Thank you!

    Only I can find is for iOS devices > > http://www.apple.com/shop/product/MJYT2AM/A/lightning-to-sd-card-camera-reader?f node = 91

    On the SDXC - Apple Support and SD card slot

    I hope someone will find an adapter for you.

  • Is it possible to use iCloud shares photos with the two opening and Photos at the same time?

    Is it possible to use iCloud shares photos with the two opening and Photos at the same time?

    Non - PEAK is not a feature of iPhoto or Aperture - this is new with Photos

    LN

  • Is it possible to use two different computers with the same adobe - ID and the same adobe license?

    Is it possible to use two different computers with the same adobe - ID and the same adobe license?

    Hi Morten,

    Yes, you can have your subscription or your license installed on two different computers with the same adobe id, however use one at a time.

    Please let us know if you have any questions, more about it.

  • This protocol uses Agent to communicate with the Service

    Hello everyone, this is my first post in this forum and I want to shoot a question if someone could help me.

    I guessed that the communication between the api and the server at the time where the user will put api HQAPi = new HQApi (...) is with the http or https protocol, depends on the value introduced in the conf file.

    I would like to know what protocol uses agent to communicate with the service. I would like your ideas.

    Thanks in advance.

    Hello

    Welcome to the forums!

    Could you clarify your question a bit more? Looking for agent-> server HQ communication or agent-> communication monitored service?

    If this is an agent-> HQ server then they communicate with each other using foam which is a specific HQ communication protocol.

    If he's an agent-> monitored service it depends on the service.

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

  • 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

  • How re - initialize an array with the new values at run time?

    Hello

    In this application of particluar I want to change the value of a particular index (Ex: 4th move in a 1 d table) and store the changed value (Inremented) in the same index position.

    I wrote a program, can someone tell what I am doing wrong?

    LabVIEW version: 8.6

    Screenshot kindly updated instead of .vi

    Two things.

    First of all:

    You must initialize the table (via the feedback loop).

    Click with the right button on the wire of the array and create constant.  Move the index of item 99.  Initialize element 0.  This thread up to the lower part of the feedback node.

    Second:

    You use an Insert in the table VI, but it's not describe what you try to do.  While he places an element in the position shown is also increases the size of the table.

    This change to a subset of table replace VI.

  • Problem with the paragraph in CS3 mac Styles

    I was wondering if anyone can help. I have a number of documents that have been created with paragraph styles by using a font that has disappeared from my machine. Now when I open my documents they look right. I changed the paragraph style in one of the documents to use a different font and now it looks fine, but all my other documents look bad. Is there anyway to set all my documents to use the updated paragraph style or will I have to change them all manually?

    There are several ways to go with this. We need to put all the files in a book,

    temporarily and being one with the correct as style definition the value the

    source, and then synchronize the paragraph styles. This will change all THE styles

    with the same names across all documents and add styles

    are present in the source, but not in any other files, so it's a bit

    risky, especially if any models are based on or [base

    Paragraph] itself is used in one of the files, and it is not already defined

    exactly the same thing in all the files.

    You can also open any file and go to the paragraph Styles Panel menu and

    Choose the command charger load styles, and then select the style you want to load, and how

    dealing with conflict (incoming use), which will give you more control over what

    is happening.

    Or whenever you open a file and get the warning of missing fonts, you can go

    Find font and select the missing font, then pcik your substitute, check the

    redefine the styles box, and then click all change. It would be probably the best

    choice since it is not the style names to make the correct changes.

  • Problem with the paragraph style "paragraph NET."

    I have a paragraph style with a paragraph in her net. There is something that I don't know what to do about it.

    When I hit 'back' to move a paragraph with this style, it leaves a rule in its wake. Here is a screenshot:

    Screen shot 2010-08-15 at 9.58.04 AM.png

    The title "Introduction" has a paragraph with a net of applied paragraph style. I put the cursor just before the word 'Introduction', press return, and it leaves a line in the previous line. Weird huh?

    Don't use not paragraph refers ALWAYS to put in place a space between paragraphs. Use the space before or after the space in the paragraph in withdrawal and spacing Style.

    If it's the beginning of a block of text and you want it to appear lower in the frame adjust them the object > text frame Options and give him a Medallion from the top. OR this way http://indesignsecrets.com/push-down-the-first-line-of-text.php

    The line of paragraph appears is because when you press back the paragraph he the same paragraph style, ergo the same paragraph style. To get rid of it, change the paragraph style from the paragraph above to something else.

    But you shouldn't really use back to add a space between paragraphs. Space before and after the space are much more effective.

    http://blogs.Adobe.com/indesigndocs/2009/05/5_typing_rules.html

    http://creativementor.com.au/adding-space-after-paragraphs

    http://help.Adobe.com/en_US/InDesign/6.0/WSa285fff53dea4f8617383751001ea8cb3f-6dcea.html

Maybe you are looking for