Insertion of array type

I tried a insertion of array type, but the error: ORA-06550 premises collection types are not allowed in SQL statements

create or replace TYPE string_array IS the TABLE OF THE varchar2 (10);

function Insert_account_numbers (in_table string_array) returns the number is

acc_array string_array;

i the number;

Start

I: = 0;

Start

insert into account_number_group

(account_number, grouped_account_number, create_date)

Select t1.column_value as a1, t2.column_value as a2, sysdate

table (in_table) t1, t2 table (in_table);

commit;

Exception when others then

I: =-1;

end;

Return i;

end;

Works for me. Please get rid of the EXCEPTION WHEN OTHERS block in the code below.

SQL> create table account_number_group(account_number varchar2(10), grouped_account_number varchar2(10), create_date date);

Table created.

SQL> create or replace type string_array is table of varchar2(10)
  2  /

Type created.

SQL> create or replace function insert_account_numbers(in_table string_array) return number
  2  is
  3    acc_array string_array;
  4    i number;
  5  begin
  6    i:=0;
  7    begin
  8      insert into account_number_group(account_number, grouped_account_number, create_date) select t1.column_value as a1, t2.column_value as a2, sysdate from table(in_table) t1, table(in_table) t2;
  9      commit;
 10    exception when others then
 11      i:=-1;
 12    end;
 13
 14    return i;
 15  end;
 16  /

Function created.

SQL> var v number
SQL> exec :v := insert_account_numbers(string_array('A','B','C'))

PL/SQL procedure successfully completed.

SQL> select * from account_number_group;

ACCOUNT_NU GROUPED_AC CREATE_DA
---------- ---------- ---------
A          A          12-NOV-15
A          B          12-NOV-15
A          C          12-NOV-15
B          A          12-NOV-15
B          B          12-NOV-15
B          C          12-NOV-15
C          A          12-NOV-15
C          B          12-NOV-15
C          C          12-NOV-15

9 rows selected.

SQL>

Note: Your function's DML statement in it. If you can not use it in the SQL statement.

Tags: Database

Similar Questions

  • Impossible to insert a 1 d table in a 2D array using "insert into array.

    Hi all

    I have a very simple problem.

    I try to insert a table 1 d as a column in a table 2D using 'insert into array"as stated in image1.

    When I try to connect the table 1 d in the "new element/sub-table" terminal I get the error indicated in image2.

    According to the help files, I should be able to wire a table of size n-1 this as the 'new item/sub-table"terminal. In other words

    I should be able to connect a table 1 d here.

    Can someone tell me what I am doing wrong?

    Thanks for your help,

    Apparently I had converted the table to float in a 'worksheet chain' and I needed to convert it into an array before sending it to 'insert into array.

    Discover image3 for more details.

  • receiver double array type send by zigbee in labview

    My question is simple. Can I receive a double array type data send by xbee and received by xbee interfaced with LabVIEW?

    It does not solve my problem. But when I use the string to byte array fuction after visa read, it solved my problem completely. Thank you

  • Storage Array Type Config path: ATAS VMW_SATP_SVC does not support the configuration of the path on ESXi 5.0 u1

    Hello

    Below for the output of my blade IBM HS22., are there any problems with the configuration of the path.

    List of paths esxcli storage nmp
    SAS.5005076b08b7aaa4 - sas.a9501097faba7a - naa.600508e0000000007abafa971050a900
    The Runtime name: vmhba0:C1:T1:L0
    Feature: naa.600508e0000000007abafa971050a900
    Full device name: FREE Serial Attached SCSI (naa.600508e0000000007abafa971050a900) drive
    Group status: Active
    Table priority: 0
    Storage Array Type Config path: ATAS VMW_SATP_LOCAL does not support the configuration of the path.
    Path selection policy path Config: {current: Yes; favorite: Yes}

    FC.2fff0000c900009f:2ffd0000c900009f - fc.500507680100 b b 680 680:500507680130 - naa.60050768018105afc000000000000df0
    The Runtime name: vmhba2:C0:T3:L2
    Feature: naa.60050768018105afc000000000000df0
    Full device name: disk of IBM Fibre Channel (naa.60050768018105afc000000000000df0)
    Group status: Active
    Table priority: 0
    Storage Array Type Config path: ATAS VMW_SATP_SVC does not support the configuration of the path.
    Path selection policy path Config: {current: Yes; favorite: Yes}

    Kind regards

    Surya

    Hi Surya,

    No, it's not any problem with the configuration of your path.

    It only means that this policy does not allow additional configuration.

    I.e. with fixed NMP, you would be able to configure a preferred path allowing you to manually distribute the i/o load.

    Your current configuration does not offer this option.

    Kind regards

    Ralf

  • change the array type in a script

    I have a script that uses a model to generate code. So far, I have a refnum in an array of doubles (the default type of the table in the model). Now, I need to change the types of elements in the array. I tried the 'set' vi in utilities VariantDataType table, but does not. How can I do this?

    Here is a way.

  • automatic generation of array type change

    For the different functions available on the table palette, there is an entry "table type".  If you right-click on the entry (on the diagram, of course) and choose Create-Constant, it creates an array of type Dbl 2D (at least it is the standard of the worksheet line to the array function).

    In this particular case, I want the type of a 2d channels table.  I know I could create a table front panel control, make dragging a control in the chain and connect then this control, but rather how can I change this constant to block diagram to be string 2d?  I don't see the option available in any context menu... once again, I want to do all this in the block diagram, not the front panel.

    Just enter the digital constant and pull it out of the constant matrix.

    Then replace it with a string constant.

    I normally just start with a blank matrix constant and place any type of constant, I need her to be inside

  • Pass String [] (String Array) type of a parameter in 'change the binding Action.

    Hello

    We hope that you do very well. It is very important for me, kindly help me in this beyond.
    I have a scenario where I pass a parameter of type String [] that have a value of {'name'} to a Web service that returns values.

    I created a datacontrol WS, dragged and decreased the value of return on a jspx, then it asks me to give the entry value

    How he move to the setting in "change the binding Action"?
    When I say new String() {'name'}, it gives me the following error
    Failed to create an object of type: [Ljava.lang.String; of type: java.lang.String with value: new String() {'name'}]

    Similarly, I hard-coded this value in a managedBean added to requestScope/applicationScope and questioned using the #{applicationScope.AppCreationBean.epsName}
    But this time, it is said, the value is null. I guess that the value is not updated correctly initialized. But if I hardcode the value in the Get accessor method, I again get the error as above.

    Someone said to me how to pass an array of type String (IE, String []) with a value of 'Name' in the Wizard "Change the binding Action" is?

    Concerning
    RaviKiran

    Hello

    refer to a property of the managed bean that returns an object. Then in the Get method / create the array and return it

    Frank

  • How to query an array type without using Loops(FOR,etc)

    Hi all

    I'm just a beginner working with oracle DB. I have a basic question about the TYPES of TABLES in oracle.

    creating table example (a number, b varchar2 (10))
    /
    Set serveroutput on;

    declare
    TYPE tab_type IS TABLE of example % ROWTYPE;
    t_tab tab_type: = tab_type();
    Start

    I'm IN 0.2
    loop
    t_tab.extend;
    t_tab (t_tab.last) .to: = i;
    t_tab (t_tab.last) .b: = "maru";
    dbms_output.put_line (t_tab (t_tab. (Last) .at);
    end loop;

    -What I CAN DO SELECT * FROM THE TABLE t_tab without using a cursor to iterate line by line
    -Since I need to compare the values in a table called HAND with this SAMPLE table.i need to check if all the files present in the table MAIN is present in the
    -Type of table table SAMPLE. I do not want to insert into a temporary table (because it becomes an overhead projector) and compare the results.
    end;

    Kindly help me in this regard and let me know if you need more details.

    Thanks in advance.

    Maybe you would like

    create type mytype as object
    (
    a number,
    b varchar2(10)
    );
    /
    create type tab_type as table of mytype;
    /
    declare
    t_tab tab_type := tab_type();
    sRES varchar2(10);
    begin
    for i IN 1..2
    loop
    t_tab.extend;
    t_tab(i) := mytype(i,'maru');
    end loop;
    
     select b
     into sRES
     from table(cast(t_tab as tab_type))
     where a = 2;
     dbms_output.put_line(sRES);
    end;
    /
    

    Published by: Alkaron on 27.03.2012 08:37

  • [Flex entry for the c# string array type: string]

    Quick question, what would be the type of entry for Flex if the data on the web service type c# asp.net is an array of strings, string [], it seems to automatically detect as an ArrayCollection, but collection which isn't fair, so I suppose that table, but I would still like to confirm this.

    Thank you

    Shaine

    It was in fact collection arraycollection:------.
    the answer is:

     

    var _compEmp:ArrayCollection = new collection ArrayCollection (new Array ("Shaine Fisher"));

    Thank you

  • Inserting data object types

    Hello
    I have the table according to object type and person in charge:
    create object type dimensions
    area number,
    volume number,
    weight number;
    
    create table objects
    id number,
    color varchar2(10),
    shape varchar2(10),
    dim dimensions,
    date_added date;
    I want to insert values only in id, color, brightness. I added the following to my code,
    insert into object (id, color, dim(area,number,weight)) values(3, 'red', dimensions(12, 34, 5));
    It gives me the following error:
    PL/SQL: ORA-00917: missing comma
    Thank you.
    SQL>  create or replace type dimensions as object(
     area number,
     volume number,
     weight number
    );
    /
    Type created.
    
    SQL>  create table objects (
     id number,
     color varchar2(10),
     shape varchar2(10),
     dim dimensions,
     date_added date
    )
    /
    Table created.
    
    SQL>  insert into objects (id, color, dim) values(3, 'red', dimensions(12, 34, 5))
    /
    1 row created.
    
  • Call a package.procedure that accepts an array type.

    I get the error message "Error (45.20): PLS-00330: incorrect use of the name of type or subtype" when I run the SP procedure when it calls the d.is_date procedure that accepts an array as the second parameter.

    Here's the short code for package.procedures that contain the "is_date.

    I tried several things and can't seem to get the SP to compile.
    Thank you.



    create or replace
    PROCEDURE SP ACE

    valid_out boolean;
    date of date_out;
    date_fmt_out varchar2 (30);

    type of Mask_Tabtype is
    table of varchar2 (30)
    index of directory;

    FMT Mask_Tabtype;

    BEGIN
    FMT (1): = 'fxDD-MON-RR ';
    FMT (2): = 'fxDD-MON-YYYY ';
    FMT (3): = 'fxDD-LUN;
    FMT (4): = ' fxMM/DD ";
    FMT (5): = ' fxMM/RRRR ";

    d.Is_Date ('test', Mask_Tabtype, Valid_out, Date_out, Date_Fmt_out);

    END SP;


    create or replace package d as

    type of Mask_Tabtype is
    table of varchar2 (30)
    index of directory;

    FMT Mask_Tabtype;

    Procedure Is_Date (Value_in in varchar2,
    Tab in Mask_Tabtype,
    Valid_out Boolean
    Date_out date,
    Date_Fmt_out out varchar2);
    end of;



    create or replace package body d as
    Whole Fmt_Count;
    Date of Date_Val: = null;
    Date_Fmt varchar2 (30): = ' fxMM/JJ/AAAA ";

    Procedure Is_Date (value_in in varchar2, Mask_Tabtype tab,
    Valid_out Boolean, Date_out date, Date_Fmt_Out out varchar2)
    is

    Start
    / * Logic here removed to make more small
    .........
    */
    End Is_date;
    End of;

    Ah, it's because you have tab_masktype stated in the package and in the calling code.

    Change your PS procedure declaration to be:

    Fmts d.Mask_Tabtype;
    

    and there is no need to declare Mast_tabtype in this procedure.

  • Problem with 'insert into array.

    First of all, sorry for my English.

    I have a problem with this function, I want to insert an item in the table of size 16 based on the index, but when I insert an element in position 4 (for example) and then I insert another element at position 2, the element that was at position 4 is moved to position 5, and I have no why understan

    Can you help me? Thank you

    Table Insert will increase the size of the table and therefore all which comes after your insert index will be its index increased by the number of items you enter.

    If you want to replace an item in a table - use "replace the subset of the table.

    Here is an example:

    Output:

  • My laptop Dell Inspiron 1525... When typing, the cursor jumps around & inserts as I type

    When you use the keyboard, the cursor will jump to another place in what I typed & insert here where it shouldn't.

    Hello

    Check with the manufacturer of system support, documentation in line, or forums as there
    probably are shortcut keys that enable and disable the touchpad functions.

    Dell - disable or enable the touchpad by using the access key
    http://support.Dell.com/support/topics/global.aspx/support/KCS/document?c=us&docid=424135&doclang=en&l=en&s=Gen&cs

    Dell support
    http://support.Dell.com/

    Dell support drivers - product manual & warranty Info (left side) - and much more
    http://support.Dell.com/support/index.aspx?c=us&l=en&s=DHS

    Dell forums
    http://en.community.Dell.com/forums/

    Parameters for TouchPad located in the control panel - mouse (there may be several tabs with)
    Entries of TouchPad) and some have a utility that loads in the Notification area near clock on
    at the bottom right.

    ==========================================

    If necessary: (make sure that you have restarted at least once, if the above did not work)

    Panel of configuration manager devices - mouse and pointing devices - Double click on the touch pad-
    The driver tab - click on Update Driver (which is may not make anything like MS is far behind certifying)
    (drivers), now right CLICK on the touchpad and UNINSTALL.

    Then go to the USB and UNINSTALL ALL controllers except the category itself (all in
    It). RESET

    This will refresh the driver for the TouchPad and battery USB. This does not prevent the touchpad
    of work.

    The similar procedure on XP, Windows 7 and Vista is the same, except that we must
    Clear the specific device if present.
    http://support.Microsoft.com/kb/310575

    Then go to the system manufacturer's website and get the latest touchpad drivers.

    Download - SAVE - go to where you put it-click on - RUN AS ADMIN.

    ==========================================

    This utility also allows to control the TouchPad:

    TouchFreeze
    http://code.Google.com/p/TouchFreeze/

    I hope this helps.

    Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle=""><- mark="" twain="" said="" it="">

  • Insert the record type

    Hi all

    I created a table with two columns method. I am assigned two values to variable recordtype.
    When inserting the record in the table, a compiler error is to be there.
    Create table emp_info(empno number(5),ename varchar2(30));
    
    DECLARE
    
    l_rec emp_info%rowtype;
    
    BEGIN
    
    l_rec.empno := 101;
    l_rec.ename := 'KING';
    
    insert into emp_info(empno,ename)
    values(l_rec);
    
    commit;
    
    END;
    ERROR on line 11:
    ORA-06550: line 10, column 35:
    PL/SQL: ORA-00947: not enough values
    ORA-06550: line 10, column 1:
    PL/SQL: SQL statement ignored


    Can I insert with output Recordtype variables indicating the column names. Can someone help me?

    Do not list of columns. Do not put brackets in the record variable:

    SQL> DECLARE
      2      l_rec emp_info%rowtype;
      3  BEGIN
      4      l_rec.empno := 101;
      5      l_rec.ename := 'KING';
      6      insert
      7        into emp_info
      8        values l_rec;
      9       commit;
     10  END;
     11  /
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    SY.

  • Cannot insert data of type string/xml in table

    I am able to read the xml through utl_file. String, but I am not able to the same insert into the table through DBMS_XMLSTORE

    CDSL_UPLOAD is the download directory
    CDSL is the username

    PL, let myself be guided if something wrong with the following script

    SCRIPT OF THE TRIAL. XML FILE

    <? XML version = "1.0"? >
    < metadata >
    -zip codes >
    -< mappings Record = "4" >
    CA < STATE_ABBREVIATION > < / STATE_ABBREVIATION >
    < ZIPCODE > 94301 < / code >
    < / maps >
    -< mappings Record = "5" >
    < STATE_ABBREVIATION > CO < / STATE_ABBREVIATION >
    < ZIPCODE > 80323 < / code >
    < ZIP_CODE_EXTN > 9277 < / ZIP_CODE_EXTN >
    < / maps >
    < / zip codes >
    < / metadata >



    CREATE TABLE TRIALZIPCODES
    (
    STATE_ABBR VARCHAR2 (20) NOT NULL
    NUMBER ZIP_CODE (10, 0) NOT NULL
    , ZIP_CODE_EXT VARCHAR2 (20)
    );


    create or replace PROCEDURE first INSTANCE AS
    BEGIN
    DECLARE
    -declaring attributes

    charString varchar2 (80);
    finalStr varchar2 (4000): = null;
    whole rowsp;
    v_FileHandle UTL_FILE. TYPE_DE_FICHIER;
    l_context_handle dbms_xmlgen.ctxHandle;
    insCtx DBMS_XMLStore.ctxType;
    DNAME varchar2 (20);
    Start
    dnom: = "CDSL_UPLOAD";

    -DBMS_XMLGEN.setRowTag (ctx IN ctxHandle, rowTag IN VARCHAR2);
    -DBMS_XMLGEN.setRowSetTag (ctx IN ctxHandle, rowSetTag IN VARCHAR2);
    -the name of the table specified in our DTD
    DBMS_XMLGEN. SETROWSETTAG ("l_context_handle,'s postal Code");
    -the name of the data set as shown in our DTD
    DBMS_xmlgen.setRowTag (l_context_handle, 'mappings');
    -to get the result on the screen
    dbms_output. Enable (1000000);
    -Open the XML document in read-only mode
    v_FileHandle: = utl_file.fopen (dname, 'trial.xml', 'r');

    loop

    BEGIN

    UTL_FILE.get_line (v_FileHandle, charString);
    exception
    When no_data_found then
    UTL_FILE.fclose (v_FileHandle);
    "exit";

    END;
    dbms_output.put_line (charstring);
    If finalStr is not null then
    finalStr: = finalStr | charString;
    on the other
    finalStr: = charString.
    end if;
    end loop;
    -for the insertion of XML data in the table
    insCtx: = DBMS_XMLSTORE. NEWCONTEXT('CDSL.) TRIALZIPCODES');
    insCtx: = DBMS_XMLSTORE. INSERTXML (insCtx, finalStr); --ALSO FAILED HERE
    dbms_output.put_line ('INSERT FACT' |) To_char (rowsp));
    DBMS_XMLStore.closeContext (insCtx);
    END;

    TRIAL END;

    Procedure returns the following error
    ORA-031011 XML parsing failed
    ORA-19202 error has occurred in the processing of xml
    LPX-00222 error returned to the SAX callback function
    ORA-06512 at SYS. XMLSTORE 70 line
    ORA-06512 CDSL. FIRST line 47
    ORA-06512 line 2

    PL I want to know what is the problem with the above script

    Thank you
    Vishal

    Indeed a few questions:

    (1) I don't see what possible use of this part:

    -- DBMS_XMLGEN.setRowTag ( ctx IN ctxHandle, rowTag IN VARCHAR2);
    -- DBMS_XMLGEN.setRowSetTag ( ctx IN ctxHandle, rowSetTag IN VARCHAR2);
    -- the name of the table as specified in our DTD
    DBMS_XMLGEN.SETROWSETTAG(l_context_handle,'zipcode s');
    -- the name of the data set as specified in our DTD
    DBMS_xmlgen.setRowTag(l_context_handle,'mappings') ;
    

    (2) not really a problem, but do not use UTL_FILE to read XML files. Oracle already provides the practice of methods or procedures to read XML efficiently with an call (see examples below).

    (3) in order to use the DBMS_XMLSTORE, the names of XML elements must match the columns in the table exactly, which is not the case here. If you cannot change the structure of the XML or the structure of the table to get an exact match, you can pre-process the file (with XSLT, for example).

    So, below is an example of using DBMS_XMLSTORE and an alternative with XMLTable that offers more flexibility:

    SQL> CREATE TABLE TRIALZIPCODES (
      2    STATE_ABBREVIATION VARCHAR2(20) NOT NULL
      3  , ZIPCODE NUMBER(10, 0) NOT NULL
      4  , ZIP_CODE_EXTN VARCHAR2(20)
      5  );
    
    Table created
    
    SQL> set serveroutput on
    SQL> DECLARE
      2
      3   xmldoc   clob;
      4   insCtx   DBMS_XMLStore.ctxType;
      5   dname    varchar2(20) := 'TEST_DIR';
      6   numrows  number;
      7
      8  BEGIN
      9
     10   xmldoc := dbms_xslprocessor.read2clob(dname, 'trial.xml');
     11
     12   insCtx := DBMS_XMLStore.newContext('TRIALZIPCODES');
     13   DBMS_XMLStore.setRowTag(insCtx, 'mappings');
     14   numrows := DBMS_XMLStore.insertXML(insCtx, xmldoc);
     15
     16   dbms_output.put_line('INSERT DONE '||TO_CHAR(numrows));
     17
     18   DBMS_XMLStore.closeContext(insCtx);
     19
     20  END;
     21  /
    
    INSERT DONE 2
    
    PL/SQL procedure successfully completed
    
    SQL> select * from trialzipcodes;
    
    STATE_ABBREVIATION       ZIPCODE ZIP_CODE_EXTN
    -------------------- ----------- --------------------
    CA                         94301
    CO                         80323 9277
     
    

    Or,

    SQL> select *
      2  from xmltable('/metadata/Zipcodes/mappings'
      3         passing xmltype(bfilename('TEST_DIR', 'trial.xml'), nls_charset_id('AL32UTF8'))
      4         columns state_abbr    varchar2(20) path 'STATE_ABBREVIATION'
      5               , zip_code      number(10)   path 'ZIPCODE'
      6               , zip_code_ext  varchar2(20) path 'ZIP_CODE_EXTN'
      7       )
      8  ;
    
    STATE_ABBR              ZIP_CODE ZIP_CODE_EXT
    -------------------- ----------- --------------------
    CA                         94301
    CO                         80323 9277
     
    

Maybe you are looking for

  • Using fully all CPU for a LabVIEW application

  • Vista update install habit and now computer is dead

    An update to my last post After all the below, he said now I have three options. Is there a way to preserve my data on my hard drive?  What is the best way to solve this problem.  I don't have the system disk. I have an old HP DV9000 to a year which

  • Designjet 110 more ink problem

    I have a Designjet 110plus, model #C7796D. I use Windows 7 Home Premium. I'm having a problem with the icons of ink on the display screen. When I try to print, the magenta icon flashes and empty bed even if there seems to be a lot of ink still in the

  • Not able to see the images in the Windows Vista Help file

    I use a Windows Vista operating system and I'm not able to view the images in the Windows Vista Help file... ! Here are the troubleshooting steps I tried to solve the problem:- I tried sfc/scannow and chkdski/f/r. Tried to clean boot. Tried to create

  • How can I change the lines using popup

    Hi allHow can I edit line on unalterable table to context-sensitive help? I'm doing a new column in the table called active.In this column: created a command link--> < af:showPopupBehavior popupId = "" / >I can't selectedrow, when I clicked on "Edit"