Error renaming dates to an associative array of type date

Hi all

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

Oracle version:

SQL > select * from v version $;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
AMT for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

Stored procedure, I try to write is as follows

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

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

JP1 PROCEDURAL errors:

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

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

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

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

output of the

  1. exec jp1

is as follows:

1ST DECEMBER 13

2 DECEMBER 13

3 DECEMBER 13

DECEMBER 4, 13

5 DECEMBER 13

DECEMBER 6, 13

7 DECEMBER 13

DECEMBER 8, 13

9 DECEMBER 13

DECEMBER 10, 13

DECEMBER 11, 13

DECEMBER 12, 13

13 DECEMBER 13

14 DECEMBER 13

15 DECEMBER 13

16 DECEMBER 13

17 DECEMBER 13

18 DECEMBER 13

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

I tried Google too for the same but without success.

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

Thanks in advance

Jagdeep Seven

Read associative arrays:

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

----

Ramin Hashimzade

Tags: Database

Similar Questions

  • error of dynamics of the associative array (pl/sql), please help

    Function down I can hard-coded but not able to go to dynamically can u please friends

    CREATE OR REPLACE FUNCTION FN_SUBSCRIPTION_BEHAVIOUR(P_YYMM IN VARCHAR2) RETURN VARCHAR2
    AS
    ARR_LIST APEX_APPLICATION_GLOBAL. VC_ARR2;
    Typ_array. ARRAY TYPE IS VARCHAR2 (16);
    array_final typ_array;
    V_ARRAY VARCHAR2 (2000);
    v_out VARCHAR2 (2000);
    v_result VARCHAR2 (2000);
    BEGIN
    ARR_LIST: = APEX_UTIL. STRING_TO_TABLE (P_YYMM, ',');
    Select LISTAGG (fid_value, ',') IN GROUP (ORDER BY fid_value) BY v_array
    of filter_detail, filter_master
    where fil_id = fid_fil_id
    and fil_position = 15
    AND NVL (fid_ACTIVE, 'Y') = 'Y ';
    array_final: = typ_array (v_array); Commented (1102,1101,1012,1011,1010,1009,1008,1007,1006,1005,1004,1003,1002,1001);
    I'm looping 1.array_final.count
    If array_final (i) in (arr_list (I)) then v_result: = '1';--Commented--(1002,1003,1007)
    Another v_result: = '0';
    end if;
    v_out: = v_out | v_result;
    end loop;
    Return v_out;
    END;


    my output is

    00000001000110

    Published by: V on March 23, 2011 21:42

    Published by: V on March 23, 2011 22:24

    Published by: V on March 23, 2011 23:00

    Published by: V on March 24, 2011 12:57 AM

    Hello

    Please check below, hope this helps.

    SQL>
    SQL> DROP TABLE tmp
      2  /
    
    Table dropped
    SQL> CREATE TABLE tmp ( col1 NUMBER)
      2  /
    
    Table created
    SQL> INSERT INTO tmp
      2      SELECT 1001 FROM DUAL UNION
      3      SELECT 1002 FROM DUAL UNION
      4      SELECT 1003 FROM DUAL UNION
      5      SELECT 1004 FROM DUAL UNION
      6      SELECT 1005 FROM DUAL UNION
      7      SELECT 1006 FROM DUAL UNION
      8      SELECT 1007 FROM DUAL UNION
      9      SELECT 1008 FROM DUAL UNION
     10      SELECT 1009 FROM DUAL UNION
     11      SELECT 1010 FROM DUAL UNION
     12      SELECT 1011 FROM DUAL UNION
     13      SELECT 1012 FROM DUAL UNION
     14      SELECT 1101 FROM DUAL UNION
     15      SELECT 1102 FROM DUAL
     16  /
    
    14 rows inserted
    SQL> COMMIT
      2  /
    
    Commit complete
    SQL> CREATE OR REPLACE FUNCTION FN_SUBSCRIPTION_BEHAVIOUR(P_YYMM IN VARCHAR2)
      2    RETURN VARCHAR2 AS
      3    ARR_LIST APEX_APPLICATION_GLOBAL.VC_ARR2;
      4    TYPE typ_array IS TABLE OF VARCHAR2(16);
      5    array_final typ_array;
      6    V_ARRAY     VARCHAR2(2000);
      7    v_out       VARCHAR2(2000);
      8    v_result    VARCHAR2(2000);
      9  BEGIN
     10    select LISTAGG(col1, ',') WITHIN
     11     GROUP(
     12     ORDER BY col1)
     13      INTO v_array
     14      from tmp;
     15    ARR_LIST := APEX_UTIL.STRING_TO_TABLE(v_array, ',');
     16    for i in 1 .. ARR_LIST.count loop
     17      if (INSTR(P_YYMM, ARR_LIST(i)) > 0) then
     18        v_result := '1';
     19      else
     20        v_result := '0';
     21      end if;
     22      v_out := v_out || v_result;
     23    end loop;
     24    return v_out;
     25  END;
     26  /
    
    Function created
    SQL> DECLARE
      2     l_out   VARCHAR2(2000);
      3  BEGIN
      4     l_out := FN_SUBSCRIPTION_BEHAVIOUR('1002,1003,1004');
      5     dbms_output.put_line(l_out);
      6  END;
      7  /
    
    01110000000000
    
    PL/SQL procedure successfully completed
    
    SQL> 
    

    Ameya

  • Error ORA to rename data/log files

    Hello

    I wanted to move my data files to the new location, and now my TEMP was not moving properly.

    SQL > bootable media.
    ORACLE instance started.

    Total System Global Area 4259082240 bytes
    Bytes of size 2166488 fixed
    922747176 variable size bytes
    3321888768 of database buffers bytes
    Redo buffers 12279808 bytes
    Mounted database.
    SQL > ALTER DATABASE RENAME FILE ' / oracleGC/oem11g/oradata/oem11g/temp01.dbf' TO ' / oradata/oem11g/data/temp01.dbf';

    Database altered.

    SQL >
    SQL >
    SQL > alter database open;

    Database altered.


    SQL > SELECT name FROM v$ datafile;

    NAME
    --------------------------------------------------------------------------------
    /oradata/oem11g/data/System01.dbf
    /oradata/oem11g/data/undotbs01.dbf
    /oradata/oem11g/data/sysaux01.dbf
    /oradata/oem11g/data/users01.dbf
    /oradata/oem11g/data/Mgmt.dbf
    /oradata/oem11g/data/mgmt_ecm_depot1.dbf

    Now, I get the following errors:


    When I try to rename, I get the error below: the dbf is in both places.

    SQL > ALTER DATABASE RENAME FILE ' / oracleGC/oem11g/oradata/oem11g/temp01.dbf' TO ' / oradata/oem11g/data/temp01.dbf';
    ALTER DATABASE RENAME FILE ' / oracleGC/oem11g/oradata/oem11g/temp01.dbf' TO ' / oradata/oem11g/data/temp01.dbf'
    *
    ERROR on line 1:
    ORA-01511: Error renaming data/log files
    ORA-01516: file nonexistent log, datafile or tempfile
    "/ oracleGC/oem11g/oradata/oem11g/temp01.dbf".

    user771256 wrote:
    Yes is working now.
    Wouldn't it appears with the following?

    SELECT NAME FROM V$ DATAFILE;

    Nope,
    Given that the file that you are interested in is a temporary file (temporary tablespace) and not of datafile he show up in v$ datafile but v$ tempfile

    Concerning
    Anurag

  • 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

  • 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

  • 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;
    
  • Associative array of index files by varchar2 - PLS 00382

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

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

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

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

    location_summary summ_arr;

    aLoc VARCHAR2 (5);

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

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

    END;

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

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

    with

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

    Nothing helps.

    Thanks in advance for your help with this.

    ANNUAL GENERAL MEETING

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

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

    Cheers, APC

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

  • An associative array in PL/SQL: key = varchar2, value = varray (varchar2)

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

    I tried to declare it like this:

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

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

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

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

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

    -----
    I also tried this:

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


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


    -j

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

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

    And if you want to add elements in varray:

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

    Or:

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

    SY.

  • SQL on an associative array

    Oracle 11.2.0.2.0

    Using UTL_FILE, I can read the text file inot successfully in the associative array.
    Now, I need to perform an advanced treatment of the values that is easily done with SQL, but for this the values should be in nested, no associative table. Is it possible a secret in another?
    Thank you.
    declare
      infile utl_file.file_type;
      v_line varchar2(100);
      v_max varchar2(100);
      i integer:=1;
      type t_lines is table of varchar2(100) index by binary_integer;
      tab_lines t_lines; 
    begin
      begin
      inFile := utl_file.fopen('ORADUMP','table.dat','R');
        loop
          utl_file.get_line(infile,v_line);
          tab_lines(i) := v_line;
          i:=i+1;
          dbms_output.put_line(v_line);
        end loop;
      exception
        when no_data_found then utl_file.fclose(infile);
        when others then
          dbms_output.put_line(dbms_utility.format_error_backtrace);
          dbms_output.put_line('error ' || sqlcode || ' '||sqlerrm);
      end;
    --How to do something like this? 
    --select max(column_value) into v_max from table(tab_lines);
    end;
    /
    P.S. I am aware of the external tables and other means of data processing, but what I basically need is the ability to make SQL on associative arrays.

    Nagornyi wrote:
    I'd use a table nested from the beginning, but how to fill only one value at a time, during the reading of the file? Sorry, I didn't do well the answer in these examples...

    Basic idea

    declare
       l_nested_table    sys.odcivarchar2list   default sys.odcivarchar2list();
    begin
       l_nested_table.extend;
       l_nested_table(l_nested_table.count) := some_value;
    end;
    /
    
  • Difference between the nested table and an associative array

    Hello
    While going through the link http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/05_colls.htm
    I came across the statement that
    Nested tables can be stored in a column of data, but of associative arrays

    So I tried the following statement for the associative arrays where he works
    create type t_nm is table of number index by binary_integer
    The t_nm of type above name is stored in USER_TYPES.


    So how can we say that associative arrays can not be stored in DB.

    Please correct me if I'm wrong.

    Thank you

    Published by: smile on April 8, 2011 02:42
    SQL> drop type t_num;
    
    Type dropped.
    
    SQL> create type t_num table of number index by binary_integer;
      2  /
    
    Warning: Type created with compilation errors.
    
    SQL> desc t_num;
    ERROR:
    ORA-24372: invalid object for describe
    
    SQL> set lines 999
    SQL> select * from user_types;
    
    TYPE_NAME                      TYPE_OID                         TYPECODE                       ATTRIBUTES
    ------------------------------ -------------------------------- ------------------------------ ----------
    T_NUM                          57417E92AD25409CB858D339570A0F56 OBJECT                                  0 
    
    SQL> select object_name, object_type, status from user_objects where object_name = 'T_NUM';
    
    OBJECT_NAME                                                                                                                      OBJECT_TYPE         STATUS
    -------------------------------------------------------------------------------------------------------------------------------- ------------------- -------
    T_NUM                                                                                                                            TYPE                INVALID
    
    SQL> 
    

    You might have missed the error into a TOAD.

    Concerning

    REDA

  • Proc 10 call Oracle stored g with associative array from c# VS 2008

    I have the following PL/SQL procedure:


    CREATE OR REPLACE PROCEDURE HMA_ADM. PRC_VDM_SAVDEL_VEN_DOC

    (

    P_OP IN VARCHAR2,

    P_USRID IN TB_VDM_MANAGE_DOCUMENTS. CREATEDBY % TYPE,

    P_DATE IN VARCHAR2,--MUST BE STRING, OTHERWISE WE GET AN ERROR

    P_DOCNAM IN TB_VDM_MANAGE_DOCUMENTS. DOCUMENTNAME % TYPE,

    P_DOCLNK IN TB_VDM_MANAGE_DOCUMENTS. BUILDER % TYPE.

    P_FNGUID IN TB_VDM_MANAGE_DOCUMENTS. FILENET_GUID % TYPE,

    P_DESC IN TB_VDM_MANAGE_DOCUMENTS. DESCRIPTION % TYPE,

    P_REQID IN VARR

    ) IS


    Where VARR is:


    CREATE OR REPLACE TYPE VARR'S ARRAY OF INTEGER;


    In c#, I have the following code:

    Int64 [] intReqID;



    OracleCommand cmdVDL = new OracleCommand (DBQueries.SPQRY_SAVDELVENDOC, connDB);



    cmdVDL.CommandType = CommandType.StoredProcedure;


    cmdVDL.Parameters.Add (new OracleParameter ("P_OP", strop));

    cmdVDL.Parameters.Add (new OracleParameter ("P_CREATEBY", strUID));

    cmdVDL.Parameters.Add (new OracleParameter ("P_CREATEDATE", strDate));

    cmdVDL.Parameters.Add (new OracleParameter ("P_DOCNAM", strDocNam));

    cmdVDL.Parameters.Add (new OracleParameter ("P_DOCLNK", strURL));

    cmdVDL.Parameters.Add (new OracleParameter ("P_FNGUID", strGUID));

    cmdVDL.Parameters.Add (new OracleParameter ("P_DESC", strDesc));

    cmdVDL.Parameters.Add (new OracleParameter ("P_REQID", OracleDbType.Int64) {}

    CollectionType = OracleCollectionType.PLSQLAssociativeArray,

    Size = intReqID.Count (),

    Value = intReqID,

    DbType = DbType.Int64,

    OracleDbType = OracleDbType.Int64

    });



    [] OracleParameterStatus stat = new OracleParameterStatus [intReqID.Count ()];


    for (i = 0; i < intReqID.Count (); i ++) {}

    STAT [i] = OracleParameterStatus.Success;

    }


    "" "cmdVDL.Parameters ["P_REQID"]." ArrayBindStatus = stat;


    cmdVDL.ExecuteNonQuery ();

    When I run the present, I get the following error:

    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in the call to 'PRC_VDM_SAVDEL_VEN_DOC '.
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored

    If I remove the associative array at the same time, the procedure works very well.

    What I am doing wrong?

    In addition,

    (1) support UDT requires ODP 11106.20 or later version (but can be used against db 10 g)
    (2) if the plsql is editable, you can exchange to an associative array rather to avoid having to create classes customized for the UDT and here is a short example of soft.
    Greg

    /*
    CREATE or replace PACKAGE MYPACK3 AS
    TYPE numarray is table of number index by BINARY_INTEGER;
    PROCEDURE getempsinarray(thearray IN numarray, numrecs out number);
    END MYPACK3;
    /
    CREATE or replace PACKAGE BODY MYPACK3 AS
     PROCEDURE getempsinarray(thearray IN numarray, numrecs out number)
     IS
     begin
      numrecs :=  thearray.count;
     END getempsinarray;
    END MYPACK3;
    /
    */
    
    using System;
    using System.Data;
    using Oracle.DataAccess.Client;
    
    public class indexby
    {
         public static void Main()
         {
          OracleConnection con = new OracleConnection("data source=orcl;user id=scott;password=tiger;");
          con.Open();
          OracleCommand cmd = new OracleCommand("mypack3.getempsinarray", con);
          cmd.CommandType = CommandType.StoredProcedure;
    
          OracleParameter Param1 = cmd.Parameters.Add("param1", OracleDbType.Int32);
          Param1.Direction = ParameterDirection.Input;
          Param1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
          Param1.Value = new int[3]{7369,7499, 7521};
          Param1.Size = 3;
    
          OracleParameter Param2 = cmd.Parameters.Add("param2", OracleDbType.Int32, DBNull.Value, ParameterDirection.Output );
    
         cmd.ExecuteNonQuery();
         Console.WriteLine("{0} records passed in",Param2.Value);
          con.Close();
         }
    }
    
  • How to: compare 2 associative arrays element-by-element

    After playing, I decided to go with the approach of the two sets of data of their own associative array.  The code and the results of this are below.  My question is the comparison.  For each element within the matrix of order, check all the items in the details table to see if there's a football game.  If there is a match > > > move to the next item in the control panel and check all the items in the details table to see if there is a football game.  Go until the whole is considered to be a match (in number of rows and values).  If no match, take the exit.

    Below, you'll see my logic to get both sets of data into their respective tables.  The results with a note attached to one of the elements is also pasted here (hereinafter the code).

    DECLARE

    TYPE details_t () IS RENDERING

    SIDE AUTO_RECIPE_DETAILS. SIDE % TYPE.

    REF_DES AUTO_RECIPE_DETAILS. REF_DES % TYPE,

    PART_NUM AUTO_RECIPE_DETAILS. PART_NUM % TYPE

    );

    TYPE details_type IS TABLE OF details_t INDEX OF AUTO_RECIPE_DETAILS. PART_NUM % TYPE;

    details_recipe details_type;

    pid_recipe details_type;

    compare_result details_type;

    CURSOR details_cur

    IS

    SELECT A FACE, REF_DES, PART_NUM

    OF AUTO_RECIPE_DETAILS

    WHERE RECIPE_NAME =' 40617-000001;

    CURSOR pid_cur

    IS

    SELECT cl. SIDE, lacpa. REF_DES, NVL(oecl.COMPONENT_ID, 'NOT APPLIED') AS PART_NUM

    OF ORDER_ERP_COMPS_LIST lacpa

    RIGHT OUTER JOIN CAD_LOCS cl

    ON cl. REF_DES = LACPA. REF_DES

    WHERE lacpa. ORDER_NUM = "PSY142420."

    AND CL. FAB = '38112';

    counter_d number (10): = 0;

    counter_p number (10): = 0;

    comp_counter number (10): = 0;

    BEGIN

    FOR rec IN details_cur

    LOOP

    counter_d: = counter_d + 1;

    details_recipe (counter_d). SIDE: = rec. SIDE;

    details_recipe (counter_d). REF_DES: = rec. REF_DES;

    details_recipe (counter_d). PART_NUM: = rec. PART_NUM;

    END LOOP;

    FOR rec IN pid_cur

    LOOP

    counter_p: = counter_p + 1;

    pid_recipe (counter_p). SIDE: = rec. SIDE;

    pid_recipe (counter_p). REF_DES: = rec. REF_DES;

    pid_recipe (counter_p). PART_NUM: = rec. PART_NUM;

    END LOOP;

    -for each pid_recipe element, double-check each record in details_recipe to see if there is an item matching (record)...

    FOR indx_d IN details_recipe. FIRST... details_recipe. LAST

    LOOP

    DBMS_OUTPUT. Put_line (details_recipe (indx_d). SIDE | ', ' || details_recipe (indx_d). REF_DES | ', ' || details_recipe (indx_d). PART_NUM);

    END LOOP;

    DBMS_OUTPUT. PUT_LINE ('IN THE SECOND PART OF IT!');

    FOR indx_p IN pid_recipe. FIRST... pid_recipe. LAST

    LOOP

    DBMS_OUTPUT. Put_line (pid_recipe (indx_p). SIDE | ', ' || pid_recipe (indx_p). REF_DES | ', ' || pid_recipe (indx_p). PART_NUM);

    END LOOP;

    END;

    /



    RESULT:


    DETAILS TABLE

    RECIPE FOR THE DETAILS TABLE:

    B, R28, 34315-26R7

    B, R38, 34315-4990

    B, R40, 34152-1R60

    B, R45, 34315-1002

    B, R46, 34315-3011

    B, R48, 34152-1004

    B, R55, 34315-5901

    B, R64, NOT APPLIED

    B, R77, 34315-4992



    CONTROL PANEL

    THE RECIPE IS CALCULATED IN THE ORDER ITSELF:

    B, C01, 39412-334 / / for that one single item-> check all the items from the table (above) details Table and see if an element matches.  Move to the next item if there is a match...

    B, C02, 39412-334

    B, C03, NOT APPLIED

    T, C11, 27249-105

    T, C13, 35404-104

    T, C14, 27531-224

    T, C15, 35404-104

    T, C18, 27249-105

    T, C19, 27531-224

    CHANGED:

    THIS... is the solution to my original question.  I had a little mistake that I set between this and my last post with this code.  Just in case a person who could use an example like that falls on this thread.

    FOR index_p IN pid_recipe. FIRST... pid_recipe. LAST

    LOOP

    Result WHEN the OUTPUT = 1;

    FOR index_d IN details_recipe. FIRST... details_recipe. LAST

    LOOP

    IF (pid_recipe (index_p). SIDE = details_recipe (index_d). SIDE)

    AND (pid_recipe (index_p). REF_DES = details_recipe (index_d). REF_DES)

    AND (pid_recipe (index_p). PART_NUM = details_recipe (index_d). PART_NUM)

    THEN

    EXIT;

    ON THE OTHER

    DBMS_OUTPUT. Put_line("IT WAS NOT a MATCH");

    result: = 1;

    EXIT;

    END IF;

    END LOOP;

    END LOOP;

    DBMS_OUTPUT. Put_line('LOOP OUT');

  • Associative array

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

    How to do?

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

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

    11g and more

    declare

    is of type tbl table of the proj_test % rowtype;

    tbl l_tbl;

    Start

    SELECT id, rn, nm bulk collect into l_tbl

    of proj_test;

    because me in 1.l_tbl.count

    loop

    dbms_output.put_line

    (

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

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

    || l_tbl (i) .nm

    );

    end loop;

    end;

    Before 11 g

    declare

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

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

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

    id_tbl l_id;

    l_rn rn_tbl;

    l_nm nm_tbl;

    Start

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

    of proj_test;

    because me in 1.l_id.count

    loop

    dbms_output.put_line

    (

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

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

    || l_nm (i)

    );

    end loop;

    end;

  • Cannot run the autonomous block for input of associative array parameter

    Hello

    I have created an associative array in a package-PKG_CMT_DAP

    TYPE r_supply_type_id IS RECORD(
                                   supply_type_id            varchar2(50));
    TYPE t_supply_type_id IS TABLE OF r_supply_type_id INDEX BY BINARY_INTEGER;
    l_supply_type_id t_supply_type_id;
    

    Later created a test procedure with an input of the above kind parameter

    create or replace
    procedure test_prc(p_in_st_id IN PKG_CMT_DAP.t_supply_type_id)
    AS
    v_input1 number;
    v_input2 number;
    BEGIN
    FOR z IN 1..p_in_st_id.COUNT 
    LOOP
    DBMS_output.put_line(p_in_st_id(z)supply_type_id);
    END LOOP;
    END test_prc;
    

    How to update successfully.

    Created a stand-alone as block below

    DECLARE
    BEGIN
    test_prc(p_in_st_id=>(100,200,300));
    END;
    

    Above am past in 100,200,300 as an input string, and the expected output should display all the numbers above on the screen.

    But it throws the below error

    Error report:
    ORA-06550: line 3, column 1:
    PLS-00306: wrong number or types of arguments in call to 'TEST_PRC'
    ORA-06550: line 3, column 1:
    PL/SQL: Statement ignored
    06550. 00000 -  "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:
    

    Could you please help me where I am doing wrong?

    Kind regards

    Claudy Kotekal

    Claudy,

    While calling the procedure, you must declare the variable of type table. Give the values for the elements in the begin block and then pass that variable in the procedure. Something like below:

    Declare

    in_array PKG_CMT_DAP. r_supply_type_id;

    Begin

    in_array (1) .supply_type_id: = 100;

    in_array (2) .supply_type_id: = 200;

    in_array (3) .supply_type_id: = 300;

    test_prc (in_array);

    end;

    NOTE: There might be a few problems with my code syntax, but logic would be same.

    Try this and let me know.

    Thank you

Maybe you are looking for