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

Tags: Database

Similar Questions

  • What is the difference between associative arrays and nested tables?

    Hello
    What is the difference between associative arrays and nested tables?

    nested tables cannot be indexed by other than pls_integer and unlike nested tables table associative cananot be declared at the schema level.

    is there any other difference set apart from the diff above 2?

    user13710379 wrote:
    What is the difference between associative arrays and nested tables?

    Name-value pairs (associative) against a list of values (table standard/nested table).

    nested tables cannot be indexed by other than pls_integer

    They are not "indexed" the way in which an associative array is indexed. A standard table is referenced by the position of the cell in the table. This position is essentially the offset of the memory of the cell from the start address of the table.

    Can not solve a cell in an associative array directly via a memory offset index. You place a cell reference value it by his 'name' (a search in the linked list/hash table).

    The following example shows the difference between the pairs of name / value and a list of core values.

    SQL> declare
      2          --// associative arrays are NAME-VALUE pairs
      3          type TArr1 is table of varchar2(10) index by pls_integer;
      4          type TArr2 is table of varchar2(10) index by varchar2(10);
      5
      6          arr1    TArr1;
      7          arr2    TArr2;
      8  begin
      9          arr1(100) := '1st entry';
     10          arr1(1) := '2nd entry';
     11          arr1(5) := '3rd entry';
     12
     13          arr2('john') := 'New York';
     14          arr2('jane') := 'Paris';
     15          arr2('jack') := 'London';
     16
     17  end;
     18  /
    
    PL/SQL procedure successfully completed.
    
    SQL>
    SQL>
    SQL> declare
      2          --// standard arrays are lists
      3          type TArr3 is table of varchar2(10);
      4          type TArr4 is table of number;
      5
      6          arr3    TArr3;
      7          arr4    TArr4;
      8  begin
      9          arr3 := new TArr3( '1st entry', '2nd entry', '3rd entry' );
     10
     11          arr4 := new TArr4( 100, 1, 5 );
     12  end;
     13  /
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    
  • 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.

  • Recovery of the records by using the Ref Cursor or indexes per Table (which is better)

    Hi all

    I am interested to know if there is a performance (or other) advantages to return a result set from an Oracle stored procedure for a client application (for example, in Java) by using a Ref Cursor or Index by Table, respectively. Most of the people I met who know Java seem to use a Ref Cursor but did not say why this method is preferable. I'm not too familiar with Java and do not have the opportunity to test the difference between either method, but I am very interested in the other user forum about this view, gauging

    Kind regards

    Kevin.

    KevinFitz wrote:
    Hi zerathul,

    Thanks for the quick and helpful response. A REF CURSOR would be the best solution if the same set of results (content and number of records returned) should be dealt with by the application of the 'customer '. I'm guessing that maybe in this situation 'theoretical' that there might be less network traffic to return the set of results through an associative array,

    Kind regards

    Kevin.

    Yes, it would always be the best solution, because an associative array would mean collecting all the data in memory of expensive PGA on the database server before they pass any return on the network, while a fair Ref cursor is to feed the data over the network (maybe a little extra load, but you were unlikely to notice). Also the client application would treat a ref as of rows returned cursor data recovery and could treat them upon their arrival, an associative array is a collection of data which will then be entirely spent before any treatment could be done and then the treatment should go through the entire table to do.

    REF CURSOR will also provide other information such as the error codes etc regarding SQL if necessary. If you get an error when filling a table on the side of the database, it is not so easy to recover this error to the client.

    REF CURSOR is designed for this purpose. Use them.

  • Difference between an associative array and Nested table

    Hello

    Can you please tell me, what is the main differences between associative array and Nested table. I'm not sure, in this case we are to use.

    Thank you and best regards,
    Sanjeev.

    user13483989 wrote:
    Hello

    Can you please tell me, what is the main differences between associative array and Nested table. I'm not sure, in this case we are to use.

    Did you happen to read the documentation, explain its good enough!
    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/composites.htm#LNPLS005

    Aman...

  • Create temporary table in the procedure

    I have a procedure which can be called at any time by multiple users. So I cann't use table in there, because on each call, the table is truncated and inserted. How can I create a temporary table in the procedure?

    Temporary tables in Oracle are different from other RDBMS like SQL Server.

    In Oracle, you create a global temporary table ONCE as part of the design of your database.

    create a global temporary table MyTableName (... columns...) on commit preserve rows;

    You can then use this table in your code as you would any other table.

    The difference is that any data that you insert in this table are only available/visible so that the code runs in the session, and if delete you / truncate the table it only removes the data for this session.  In this way, several sessions we can table without interfering with each other.

    (Note: instead of "preserve" you can change this to "delete" If you want that deleted data automatically when a commit is issued in your session, otherwise the data will be automatically deleted at the end of the session)

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

  • BEGINNING about the object type indexes per table

    Hi all

    I've been tyring just what follows.

    declare
    type ty_tab is table of the directory index ty_test;

    my_tab ty_tab;

    Start
    my_tab (1):=ty_test(1111,ty_info('ashok',1000));
    my_tab (2):=ty_test(2222,ty_info('Rashmi',2000));
    my_tab (3):=ty_test(3333,ty_info('unknown',3000));

    for me in my_tab.first... loop of my_tab. Last

    dbms_output.put_line (my_tab (i) .empno |) » '|| my_tab (i) .info);

    end loop;

    end;

    /

    When running the script, I get the following error.
    ORA-06550: line 13, column 25:
    PLS-00306: wrong number or types of arguments in the call to ' |'
    ORA-06550: line 13, column 4:
    PL/SQL: Statement ignored

    Can anyone suggest?


    Thanx

    the attributes of the type ty_info assuming that are name and val:

    dbms_output.put_line(my_tab(i).empno||' '||my_tab(i).info.name||' '||my_tab(i).info.val);
    

    SY.

    Published by: Solomon Yakobson, March 16, 2010 05:01

  • At all indexes on tables of the same value in the structure of the event

    Hello

    I have a panel with the four bays and I use a structure of the event.

    Now, I want that change of the index of array_1 also affects the index of 3 other tables at the same index.

    But there is only a property "value Exchange" and no property 'index-change' in the properties of the table.

    So I read the 'index' property and write in the other table.

    But: It seems as if I have to do so within the period of waiting-section of the structure of the event.

    Is there another way to do this?

    Thanks for help

    You can use the mouse event on each table to detec the event (of course, that will attract not only a change of index, but I don't think you care too) and then use the 'values of the indices' property on all the table to set.

    See annex VI (LV2012), hope this helps

  • ODI - 1228 error when you try to delete a table using the procedure

    Hello

    I get the following error when I run the procedure. The process has two steps.

    Step 1: Drop table (REF_TABLE1 ;) removal
    Step 2: Complete the Table (Insert statements)

    ODI-1228: Load_Ref_Roles_Privileges_List (procedure) of the task fails on ORACLE DEVSCHEMA target connection.
    Caused by: java.sql.SQLSyntaxErrorException: ORA-00911: invalid character

    CODE: delete from REF_TABLE1;

    When I run the same delete statement into a TOAD, it works. Also, if I run it with only step2 it works.

    Please notify. Thanks for your time and your help.

    Hello

    Could you try without the *. * ?

    Only

    delete from REF_TABLE1
    

    Kind regards
    JeromeFr

  • pl - sql query with indexes per table

    Hello again,

    I'm stuck with this query, I want to display the full name of all employees, using the HR schema table.

    DECLARE
    Employee_table_struct TYPE IS an ARRAY OF
    HR. Employees.first_name%type
    INDEX OF DIRECTORY;

    employee_table employee_table_struct;

    Employee_cursor CURSOR IS
    SELECT first_name
    OF hr.employees;


    v_row NUMBER: = 1;
    BEGIN

    OPEN employee_cursor;

    LOOP
    OUTPUT WHEN employee_cursor % NOTFOUND;

    DBMS_OUTPUT. Put_line (employee_table (v_row));

    -populated the next time the loop * /.
    v_row: = v_row + 1;
    END LOOP;

    CLOSE Employee_cursor;
    END;
    /

    Its gives me error saying:

    ORA-01403: no data found
    ORA-06512: at line 21

    Help, please
    Thank you

    Why not use a clear FOR the loop?
    It allows you to save saying stuff and it does the same thing, showing first_name for all employees:

    begin
      for rec in ( select first_name
                   from   hr.employees
                 )
      loop
        dbms_output.put_line(rec.first_name);
      end loop;
    end;
    /
    
  • 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...

  • Select the entire table in the procedure

    I want to create a procedure that selects all rows in the object with the following select statement:

    SELECT r.firstname, r.lastname,
    r.Address.streetname, r.address.city.postalnumber, r.address.city.cityname,
    (SELECT t.phonenumber
    Channels3 p, of the table (p.phonelist) t WHERE deref (t.phonetype) .phonetypename = "passenger".
    AND (p) REF = REF (r)
    ) as passenger.
    (SELECT t.phonenumber
    Channels3 p, of the table (p.phonelist) t WHERE deref (t.phonetype) .phonetypename = "mobile"
    AND (p) REF = REF (r)
    ) as mobile,.
    (SELECT t.phonenumber
    Channels3 p, of the table (p.phonelist) t WHERE deref (t.phonetype) .phonetypename = "percentages".
    AND (p) REF = REF (r)
    ) as Naing
    From channels3 r

    but I don't know how to do it correctly. Can someone tell me how can I do this? THX

    you would need a refcursor.

    create or replace procedure my_proc(pRc out sys_refcursor)
    as
    begin
      open pRc for select * from person;
    end;
    

    call this in c# code. You can store the result in a DataSet.

  • Index associative arrays in varchar2

    Hi all
    It seems that associative arrays are indexes by varchar2
    automatically sorted by index value.
    Please run this test:
    declare 
    
      TYPE TEST_ARRAY IS TABLE OF VARCHAR2(10) INDEX BY VARCHAR2(10);
      aTest TEST_ARRAY;
      
      cIndex VARCHAR2(10);
    begin
      -- Test here
      aTest('X') := 'X';
      aTest('A') := 'A';
      aTest('C') := 'C';
      aTest('Z') := 'Z';
      aTest('C') := 'C';
      aTest('B') := 'B';
      aTest('AB') := 'AB';
      aTest('12') := '12';
      
      cIndex := aTest.FIRST;
      while cIndex IS NOT NULL LOOP
              dbms_output.put_line('aTest('||cIndex||')='||aTest(cIndex)); 
              cIndex := aTest.NEXT( cIndex );
      END LOOP;
       
    END;
    Now, the questions are:
    1. are you aware of the documentation of Oracle that describe the behavior above?
    2. are you aware of no example where associative arrays index in varchar2
    is not sorted by its index? (Finally, except changing the NLS_SORT setting)
    3. is it safe to use this feature of "sort"?

    Thank you
    Thomas

    1. are you aware of the documentation of Oracle that describe the behavior above?

    " Associative arrays: ' indexes are stored in the sort order, not order of creation '."

  • 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

  • Instead of my AOL Homepage, I get "Ask Jeeves" whenever I have the log - on for firefox, please help

    I don't know how it got on my system, but I got a window called 'ask Jeeves', whenever I connected on Firefox 4 Beta. I want my homepage 'AOL '. I keep trying to put in the "box of the House and that seems to work, but I don't want to have to open fi

  • How to get the Installation of Vista from Toshiba disk?

    I work with Microsoft technical support to solve a security problem on my Satellite Pro A210 and were now required to use a Vista installation disc. Microsoft says that I am entitled to an installation of the original provider of my kit disc - Toshib

  • Microsoft Office Outlook 2007

    Hello I get this message when I try to open Microsoft Office Outlook:Cannot start Microsoft Office Outlook.  Cannot open the Outlook window. Can you help me? Thank you

  • Please provide details on troubleshooting performed.

    I noticed a lot of posts where authors are making a general statement that they have tried all troubleshooting steps already. Troubleshooting is the process of elimination, and a general statement like that leaves someone who may want to help with no

  • Click to open topics in the Index and the 'Search' tab

    I have the setting "Single click to open books" archived on parameters HTML Adv.  It works very well.  Wooo hoo!  My QA people are so happy with this feature they want the feature click to open topics in the index and search tabs.  I can't find anywh