Table of multiplication using associative arrays

DB version: 10.2.0.1.0

Here is a code for the multiplication of 14 up to 100 table. How can I store these values in an associative array and each element of the Bulletin Board so that it produces the same output as the code below.
Declare
--TYPE v_number_type IS TABLE OF number INDEX BY PLS_INTEGER;

v_number     number:= 14;
v_multiplied_by     number:= 1;
v_result     number;
begin

     for i in 1..100
     loop
          v_result:=     v_number * v_multiplied_by;
          dbms_output.put_line(v_number||' multiplied by '||v_multiplied_by||' = '||v_result);
          v_multiplied_by:=v_multiplied_by + 1;
     end loop;
 
 end;
 /
Result would be
 14 multiplied by 1 = 14
 14 multiplied by 2 = 28
 14 multiplied by 3 = 42
 14 multiplied by 4 = 56
 14 multiplied by 5 = 70
 .
 .
 .
 
Published by: user609308 on March 12, 2009 03:09
Including the
 tags                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

It's a bad habit to "select into... of double" where you could just assign a value.
It's your code, that boiled down to this:

DECLARE
   TYPE v_number_type IS TABLE OF VARCHAR2(40)
      INDEX BY PLS_INTEGER;

   v_number     PLS_INTEGER   := 14;
   v_res_type   v_number_type;
BEGIN
   FOR i IN 1 .. 100 LOOP
      v_res_type(i) := TO_CHAR(v_number) || ' multiplied by ' || TO_CHAR(i) || ' = ' || TO_CHAR(v_number * i);
   END LOOP;

   FOR j IN v_res_type.FIRST .. v_res_type.LAST LOOP
      DBMS_OUTPUT.put_line(v_res_type(j));
   END LOOP;
END;
/

Tags: Database

Similar Questions

  • Error in the pl/sql block using associative arrays

    Hello
    I tried the following block of code using associative arrays.
    DECLARE
       TYPE NumTab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
       CURSOR c1 IS SELECT empno FROM emp;
       empnos NumTab;
       rows   NATURAL := 10;
    BEGIN
       OPEN c1;
       FOR i in empnos.first..empnos.last LOOP
          /* The following statement fetches 10 rows (or less). */
          FETCH c1 BULK COLLECT INTO empnos LIMIT rows;
          EXIT WHEN c1%NOTFOUND;
          DBMS_OUTPUT.PUT_LINE ( empnos.next(i)); 
       END LOOP;
       CLOSE c1;
    END;
    and the error is
    DECLARE
    *
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at line 8
    could you please let me know where I am going wrong
    and please guide me where we use these associative arrays.

    Thank you

    Try this

    DECLARE
       TYPE NumTab IS TABLE OF emp%rowtype INDEX BY PLS_INTEGER;
       CURSOR c1 IS SELECT * FROM emp;
       empnos NumTab;
       rows   INTEGER := 10;
    BEGIN
      OPEN C1;
      LOOP
        FETCH c1 BULK COLLECT INTO empnos LIMIT rows;
        EXIT WHEN c1%NOTFOUND;
    
        FOR i IN 1..empnos.count
        LOOP
          DBMS_OUTPUT.PUT_LINE(empnos(i).empno || '/' || empnos(i).ename);
        END LOOP;
      END LOOP;
    END;
    
  • Using associative arrays in query

    Hi all

    Please see my schedule. It works very well

    [CODE]

    DECLARE

    type mechanics_type_tab is table of index varchar2 (15) by varchar2 (15);

    l_mechanics_type mechanics_type_tab;

    L_BULLETIN t_tfo_wf_varchar_table:=t_tfo_wf_varchar_table();

    l_count pls_integer: = 0;

    BEGIN

    FOR I IN (select bulletin_id, mechancs_type_id

    of TFO_BULLETIN_PROMO_MECHANICS

    where mechancs_type_id is not null) LOOP

    l_count: = l_count + 1;

    l_mechanics_type (i.bulletin_id): = i.mechancs_type_id;

    l_mechanics_type (i.mechancs_type_id): = i.mechancs_type_id;

    L_BULLETIN.extend;

    L_BULLETIN (l_count): = i.bulletin_id;

    END LOOP;

    FOR J IN (SELECT TABLE COLUMN_VALUE (L_BULLETIN)) LOOP - this will change

    DBMS_OUTPUT. Put_line ('COLUMN_VALUE =' | l_mechanics_type (J.COLUMN_VALUE));

    END LOOP;

    / * does not

    Insert into test_table (test1)

    SELECT values l_mechanics_type (COLUMN_VALUE) OF TABLE (L_BULLETIN); */

    END;

    [/ CODE]

    instead of the code below:

    FOR J IN (SELECT TABLE COLUMN_VALUE (L_BULLETIN)) LOOP - this will change

    DBMS_OUTPUT. Put_line ('COLUMN_VALUE =' | l_mechanics_type (J.COLUMN_VALUE));

    END LOOP;

    When I did as below

    [CODE]

    insert into test_table (test1) to

    SELECT values l_mechanics_type (COLUMN_VALUE) OF TABLE (L_BULLETIN);

    [/ CODE]

    It does not work. Why it does not work.

    Please note that in the real-world scenario, there are several fields to insert for test_table and test1 is one of them.

    Just because the associative arrays are not supported in SQL before ORACLE 12 c.

    HTH

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

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

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

  • CURSOR for loops or an associative array

    I just want to know the advantages and disadvantages of the CURSOR for loops. As a general rule, what guys do you prefer: associative array with CURSOR for loops?


    If you use the CURSOR for loop, is it not difficult to debug?

    PL/SQL Developer, I do not see what values are stored in the CURSOR for loop (in SP master_proc below) as
    There are no variables to watch. Not sure if the TOAD can show these values

    If I had used an associative array (master_proc2 below), I can see the values stored in the table by clicking on "show Collection"variable in PL/SQL developer.




    create table emp2 as select * from emp;
    
    
    create or replace procedure my_proc(p_empno in number)
    as
    begin
    update emp2 set sal=sal+100 where empno=p_empno;
    end;
    /
    
    --Using CURSOR FOR loop
    
    create or replace procedure master_proc
    as
    begin
         for rec in (select empno from emp2 where empno>7700)
         loop
              my_proc (rec.empno);
         end loop;
    end;
    /
    
    -- Using Associative arrays
    create or replace procedure master_proc2
    as
    type v_empno_type is table of number index by pls_integer;
    v_empno v_empno_type;
    
    begin
    select empno bulk collect into v_empno from emp2 where empno>7700;
    
    for i in 1..v_empno.count
     loop
        my_proc (v_empno(i));
     end loop;
    end;
    /

    VitaminD wrote:
    Thank you Tubby. If you are faced with a situation where you MUST use a loop. Then you would go to associative arrays rather than CURSOR FOR loops. Right?

    Doesn't happen too often, but if/when then I would do as I said in my first post. Use the transformation, the collection table in BULK and FORALLs.

    If we use your example posted, I would NOT spend a single table (in a loop mode) value I would be transmitted in the OVERALL picture and treat it with FORALL.

    So, I would still use neither of the approaches that you mentioned.

  • 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

  • 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

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

  • Difference between an associative array, table etc.?

    Hello

    I wonder what are the differences in comparison with these? They seem similar, but a table need a custom c# and the associative array type class does not. When should you use that? Say I want to pass a collection of numbers to a perhaps stored procedure?

    You want to test something to appropriate for what your use to gauge that.

    I just did a quick test and associative is quite a bit faster than the UDT for my test regarding the disappearance of the object and the invocation of the proc (I went from size 1000 channels 2000), but I've also used an empty body of the stored procedure and the proc in fact might affect things.

    Here is my code if you want to test. I used ODT to generate the V2TYP class and then changed string [] m_V2TYP; to the public within this category just for ease of use.

    It will be useful,
    Greg

    /*
    create type v2typ is table of varchar2(4000);
     /
    create or replace package testpack as
    TYPE v2array is table of varchar2(4000) index by BINARY_INTEGER;
    PROCEDURE test_assoc_array(v2arr1 IN v2array);
    procedure test_udt(v2udt in v2typ);
    END;
    /
    CREATE or replace PACKAGE BODY testpack AS
    PROCEDURE test_assoc_array(v2arr1 IN v2array) IS begin null; END;
    procedure test_udt(v2udt in v2typ) is begin null; end;
    END;
    /
    */
    
    using System;
    using System.Data;
    using Oracle.DataAccess.Client;
    namespace compare_assocarray_and_udt
    {
        class Program
        {
            static string constr = "data source=orcl;user id=scott;password=tiger;";
            static void Main(string[] args)
            {
                int numelements = 1000;
                string[] vals = new string[numelements];
                for (int i = 0; i < numelements; i++)
                    vals[i] = new string('a', 2000);
    
                V2TYP myv2typ = new V2TYP();
                myv2typ.m_V2TYP = vals;
    
                test_assoc_array(vals);
                test_udt(myv2typ);
            }
    
            static void test_assoc_array(string[] vals)
            {
                using (OracleConnection con = new OracleConnection(constr))
                {
                    con.Open();
    
                    using (OracleCommand cmd = new OracleCommand("testpack.test_assoc_array", con))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        OracleParameter Param1 = cmd.Parameters.Add("param1", OracleDbType.Varchar2);
                        Param1.Direction = ParameterDirection.Input;
                        Param1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
                        Param1.Size = vals.Length;
                        Param1.Value = vals;
                        DateTime start = System.DateTime.Now;
                        cmd.ExecuteNonQuery();
                        Console.WriteLine("assoc array elapsed: {0}ms", (System.DateTime.Now - start).TotalMilliseconds.ToString());
                    }
                }
            }
    
            static void test_udt(V2TYP val)
            {
                using (OracleConnection con = new OracleConnection(constr))
                {
                    con.Open();
    
                    using (OracleCommand cmd = new OracleCommand("testpack.test_udt", con))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        OracleParameter Param1 = cmd.Parameters.Add("param1", OracleDbType.Object);
                        Param1.Direction = ParameterDirection.Input;
                        Param1.UdtTypeName = "SCOTT.V2TYP";
                        Param1.Value = val;
                        DateTime start = System.DateTime.Now;
                        cmd.ExecuteNonQuery();
                        Console.WriteLine("udt elapsed:         {0}ms", (System.DateTime.Now - start).TotalMilliseconds.ToString());
                    }
                }
    
            }
        }
    }
    
  • Table binding error ORA-01485 when I try to get in an associative array

    Hello

    I test to pass in an array associative odp.net

    So I created a simple testpackage:
    CREATE TABLE jwetesttab (CLIENTNR NUMBER (10) NOT NULL);

    CREATE OR REPLACE PACKAGE IN THE JWETEST_PK
    TYPE t_CLIENTNRS IS TABLE OF NUMBER INDEX OF PLS_INTEGER;
    PROCEDURE TestArrayIn (p_CLIENTNRS IN t_CLIENTNRS, p_NbOfRowsInserted OUT NUMBER);
    END JWETEST_PK;
    /

    CREATE OR REPLACE PACKAGE BODY JWETEST_PK AS
    PROCEDURE TestArrayIn (p_CLIENTNRS IN t_CLIENTNRS, p_NbOfRowsInserted ON the NUMBER)
    IS
    BEGIN
    FORALL i IN p_CLIENTNRS.first... p_CLIENTNRS. Last
    INSERT INTO jwetesttab (CLIENTNR) VALUES (p_CLIENTNRS (i));
    p_NbOfRowsInserted: = SQL % ROWCOUNT;
    COMMIT;
    END TestArrayIn;
    end JWETEST_PK;
    /

    Then I did as simple testapp as follows:
    Protected Int As Integer = 0
    Dim arrNums() As Integer = {1, 2, 3}
    Dim cmd As New OracleCommand
    Dim cnn as new OracleConnection (s_conn)
    Try
    With cmd
    . ArrayBindCount = 3
    . Connection = cnn
    . CommandText = "JWETEST_PK. TestArrayIn ".
    . CommandType = CommandType.StoredProcedure

    Var p_Clientnrs As OracleParameter = New OracleParameter
    With p_Clientnrs
    . ParameterName = "p_CLIENTNRS."
    . DbType = DbType.Int32
    . CollectionType = OracleCollectionType.PLSQLAssociativeArray
    . Value = arrNums
    . Size = 3
    Ends with
    . Parameters.Add (p_Clientnrs)
    . Parameters.Add (New OracleParameter ("p_NbOfRowsInserted", OracleDbType.Int32, ParameterDirection.Output))
    CNN. Open()
    cmd ExecuteNonQuery()).
    Int = CInt (.) Parameters ("p_NbOfRowsInserted"). Value)
    Ends with

    Catch ex As Exception
    MsgBox (ex.) Message)
    Finally
    If (cnn IsNot Nothing) = False Then
    CNN. Close()
    CNN. Dispose()
    End If
    End Try

    When I run my testapp, the lines are inseterd in the database, but it gives me an error: link table error: ORA-01485

    Liaison of the table and the associative arrays are two different functions and tend to confuse because they both have the word Array in them.

    The table binding is for "run this procedure and statement number X times, all the data here is at the front. ''
    Associative array is to "perform this procedure once, here is the table I want to that you pass in.

    Start by removing ArrayBindCount = 3and see if that helps

    If you still have problems, see the example of associative array on your hard disk to %OH%\ODP.NET\samples\2.x\AssocArray

    It will be useful,
    Greg

  • 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

  • Using the procedure to display the table of multiple data

    Hi, I need help for the procedure in oracle

    I want to create the procedure to display the table of multiples with sample plan

    with a parameter imployee_id to display an employee_id, name, function, start_date, end_date

    IAM using this query to select more than one table

    SELECT e.employee_id, e.first_name, j.job_title, h.start_date, h.end_date

    E EMPLOYEES

    JOIN j jobs

    ON j.job_id = e.job_id

    JOIN the job_history:

    ON h.employee_id = e.employee_id

    WHERE e.employee_id = 200;

    Thanks for the help

    Blu and Billy showed you the 'real' solution. You can display the data returned by a cursor ref in SQL Developer, too:

    http://www.thatjeffsmith.com/archive/2011/12/SQL-Developer-tip-viewing-refcursor-output/

    Yet as a duty for a beginner is generally do not have the expected solution. Usually, teachers want to see you using a LOOP and dbms_output. something like

    DECLARE

    Xy CURSOR IS

    SELECT whatever

    As much as;

    BEGIN

    FOR r IN xy LOOP

    dbms_output.put_line (r.col1 |' # ' | r.col2);

    END LOOP;

    END;

    Of course this suggestion will inaugurate a discussion abusing DBMS output but I keep my position that it is authorized to use it for learning the basics.

Maybe you are looking for

  • Marker for iBook

    Hello When I sync a PDF in iBooks, I can't mark a text or a Word. If there is no marker in iBook, please add it. Because it is necessary. (I use the latest version of iOS and iBook) Thank you very much

  • How can I change the fingerprint logon?

    I had a local guru clean my Dell laptop. He called and said he was not able to connect and I gave him the password to get connected. When I took the computer he told me that he had changed the fingerprints to a fingerprint logon. I want to erase her

  • card PCI e on m51 8142-car

    Hello I'll have abit of some problems and hope someone can help me with this. I just got a sapphire radeon hd5550 graphics card and I was wondering how can I disable the graphic edge so he could get out the box. I updated a 400 watt power supply and

  • install win7 clean E320

    Hello I put the new HARD drive to my new ThinkPad Edge E320 (1298) and I installed 64-bit win7sp1. I found the driver download page but I don't know what to install and in what order... I just need working card graphics, wifi, ethernet and turn off w

  • Defender of Windows 8

    Three years ago the Defender has been uninstalled on my pc Windows 8.0. I can re-installed on my pc today?