Problem creating an nested table.

Hi,
I try to create a type of mytable%rowtype:
create type test_type is table of mytable%rowtype;
The response is:
Type created with compile errors. (<- free translation from german ;)
Creating a table of varchar2(100) works as expected.
Is this a license restriction of XE or am I just too stupid for this?
Thanks in advance.
Thomas

As far as I know this limitation is not an XE limitation, you can check for the other editions also.
%TYPE and %ROWTYPE can be used within PL/SQL, not SQL.
DECLARE
     TYPE Cust_tab IS TABLE OF                        
          Customers_Active%ROWTYPE;
     Custs   Cust_tab;
BEGIN
     SELECT Customer_Account_Id, Effective_Date,
               Expired_Date
           BULK COLLECT INTO Custs
     FROM Customers_Active;
END;
DECLARE
   emprec    employees_temp%ROWTYPE;
BEGIN
   emprec.empid := NULL; 
   emprec.deptid := 50;
   DBMS_OUTPUT.PUT_LINE('emprec.deptname: ' || emprec.deptname);
END;
/

Similar Messages

  • Problem in creating a nested table

    Hi i am working on Oracle 10g and cleint is sqlplus.
    Now while creating a nested table following error occured.
    This is the script for your reference.:
    CREATE OR REPLACE TYPE sec_pwd_hist_table
    AS
    TABLE OF sec_pwd_history_type
    index by binary_integer
    Warning: Type created with compilation errors.
    SQL> show error
    Errors for TYPE SEC_PWD_HIST_TABLE:
    LINE/COL ERROR
    0/0      PL/SQL: Compilation unit analysis terminated
    3/1      PLS-00355: use of pl/sql table not allowed in this context
    Please help on this issue
    Regards,
    Vikas Kumar

    > but i want to know just one thing why its working when i am removing "INDEX BY binaty_integer"
    Vikas, I trust I answered that question when I said? :
    "Do not confuse the two. Do not attempt to use PL/SQL array struct definition syntax in the SQL engine for defining an ADT collection. Which is why I referred you to the manual to see how an ADT is defined in SQL."
    In other words, you are trying to apply a PL/SQL concept and PL/SQL syntax to a definition of a data type in SQL.
    SQL is not PL/SQL.
    SQL ADTs are not PL/SQL arrays/tables.
    It is not even a syntax issue - it is a basic concept issue. SQL does not support PL/SQL arrays/tables. Period.

  • Problem in using Nested TABLE

    Hi ,
    I created 2 Nested Table & tried to insert the data in Table through Procedure but it gave an err msg.
    create type name as object
    (fname varchar2(20),
    mname varchar2(20),
    lname varchar2(20));
    create type address as object
    (city varchar2(20),
    state varchar2(20),
    pin varchar2(20));
    create type ename as table of name;
    create type eaddress as table of address;
    create table emp_rec
    (employee_id varchar2(5),
    employee_name ename,
    employee_address eaddress)
    nested table employee_name store as empname,
    nested table employee_address store as empaddress;
    insert into emp_rec
    values('1',
    ename(name('anand','kumar','chouksey')),
    eaddress(address('vashi','mh','400093')));
    //Data Inserted
    //Procedure for Inserting Another Data Works
    create or replace procedure nest_proc
    is
    begin
    insert into
    the
    (select employee_address from emp_rec where employee_id=1 ) e
    values('jbp','mp','482002');
    --where employee_id=1;
    end;
    begin
    nest_proc;
    end;
    PL/SQL procedure successfully completed.
    //But if i'll try to insert the data into 2 nested tables then gets failed.
    create or replace procedure nest_proc
    is
    begin
    insert all into
    the
    (select employee_name,employee_address from emp_rec where employee_id=1 ) e
    values('x','y','z');
    into the(select employee_address from emp_rec where employee_id=1 ) e
    values('a','b','c');
    --where employee_id=1;
    end;
    Kindly help me out.
    Rgrds,
    Anand

    Hi,
    Thanks for replying ,actually i did the mistake. I'm using multitable insert stmt. on 2 different tables that's why it gave an err msg.Instead of using multitable insert stmts i used 2 insert stmt. on Procedure & it gets compiled.
    Regards,
    Anand

  • Object Modelling Question: How do I create multiple nested table columns in one table

    Hi there,
    I have a XML doc which is as follows:
    <PERSON>
    <ADDRESSLIST>
    <ADDRESS>111, Hamilton Ave </ADDRESS>
    <ADDRESS>222, Cambell Ave </ADDRESS>
    </ADDRESSLIST>
    <PHONELIST>
    <PHONENO>4085551212 </PHONENO>
    <PHONENO>6505551212</PHONENO>
    </PHONELIST>
    </PERSON>
    I need a table that looks as follows:
    Create table person
    (addresslist address_table,
    phonelist phone_table
    I would like to create a table called person with columns addresslist and phonelist. Each defined as object type table of address and table of phones.
    Can anybody please tell me how can I do this.
    I have seen that there can only be one nested table per table. If so, how do we do this.
    Thanks so much
    Pramod

    pelle.k wrote:
    peets wrote:Hehe because it's less typing!
    Good one!
    Also, it's by far the more dynamic method.
    If you want to get pedantic, it's also far less efficient in terms of execution time: each iteration of the loop forks a new process, whereas using a single mkdir command forks only once.  The "best" way is the curly-braces method demonstrated above by chimeric.

  • Problem creating an internal table dynamically

    Hi,
    I'm trying to create an internal table dynamically as i would be able to determine the structure of the table based on the user input.
    I've used the sample code from this forum ...
    REPORT  ZRICH_0003       .
    type-pools: slis.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>,
                   <dyn_field>.
    data: alv_fldcat type slis_t_fieldcat_alv,
                   it_fldcat type lvc_t_fcat.
                   type-pools : abap.
    data : it_details type abap_compdescr_tab,
           wa_details type abap_compdescr.
    data : ref_descr type ref to cl_abap_structdescr.
    data: new_table type ref to data,
          new_line  type ref to data,
          wa_it_fldcat type lvc_s_fcat.
          selection-screen begin of block b1 with frame title text.
    parameters: p_table(30) type c.
    selection-screen end of block b1.
    Get the structure of the table.
    ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
    it_details[] = ref_descr->components[].
    loop at it_details into wa_details.
      clear wa_it_fldcat.
      wa_it_fldcat-fieldname = wa_details-name .
      wa_it_fldcat-datatype = wa_details-type_kind.
      wa_it_fldcat-inttype = wa_details-type_kind.
      wa_it_fldcat-intlen = wa_details-length.
      wa_it_fldcat-decimals = wa_details-decimals.
      append wa_it_fldcat to it_fldcat .
      endloop.
    Create dynamic internal table and assign to FS
    call method cl_alv_table_create=>create_dynamic_table
                exporting
                it_fieldcatalog = it_fldcat
                importing
                ep_table        = new_table.
    assign new_table->* to <dyn_table>.
    Create dynamic work area and assign to FS
    create data new_line like line of <dyn_table>.
    assign new_line->* to <dyn_wa>.
    <b>* Select Data from table.
    select * into table <dyn_table>           from
    (p_table).</b>
    Write out data from table.
    loop at <dyn_table> into <dyn_wa>.
    do.
    assign component  sy-index  of structure <dyn_wa> to <dyn_field>.
    if sy-subrc <> 0.
    exit.
    endif.
    if sy-index = 1.
    write:/ <dyn_field>.
    else.
    write: <dyn_field>.
    endif.
    enddo.
    endloop.
    I'm able to get the structure of the table that i want, but when i'm trying to select data from the table into this internal table..as highlighted in the sample code above..i'm getting a short dump...saying that ' the database table is 600 bytes wide but the internal table is only 576 bytes wide.
    The internal table is declared as
    field-symbols: <dyn_table> type standard table..
    Could anyone please tell me how to rectify this.
    Thanks in advance,
    Harsha.

    Hi Smitha,
    I'm building the internal table by getting the structure using the method
    cl_abap_typedescr=>describe_by_name( p_table ).
    where p_table is the table name determined dynamically..
    Now using this structure, i'm building an internal table by calling the method
    call method cl_alv_table_create=>create_dynamic_table
    I've checked all the fields after the internal table has been created .. and it contains all the fields of the table that i'm supplying initially..
    But when i read data into that internal table, it gives me that dump..I've described it in this post earlier.
    Any more suggestions would be very helpful.
    Thanks,
    Harsha

  • Labview database problem: Create a database table from user defined fields

    I am trying to create a new table in an access database opened by an ODBC connection from information entered a table stored in the database, but every time I try to create the table, the Labview Database connectivity toolkit VI for creating a table throws a cryptic error
    "Exception occured in Microsoft OLE DB Provider for ODBC Drivers: [Microsoft][ODBC Microsoft Access Driver] Syntax error in field definition. in NI_Database_API.lvlib:Conn Execute.vi->NI_Database_API.lvlibB Tools Create Table.vi->DatabaseCreateHeaders.vi"
    I think this is becuase I am trying to re-create the database  column variable type, but I am not sure what I am doing wrong.  Everything seems to be fine as the data types go, and everything works as long as I use a constant to create the database columns.  I even tried putting all of the information into the format labview defined, changed that to a variant, and redefined it as the labview database column type. 
    I have attached a simplified VI and a picture of what I am trying to
    do, but I would appreciate any help I can get.  Hopefully I won't have
    pulled out all of my hair by the time some one replies!
    Solved!
    Go to Solution.
    Attachments:
    DatabaseUserDefinedTable.vi ‏14 KB
    UserDefinedColumns.JPG ‏48 KB

    Hi everyone. I am new to the database tool kit using labview. I am using labview 9.0f2 on Windows Xp. I am required to create a database (task is to create a table and to insert values into the table using Microsoft access 2007). I am trying to learn using the Create Database table.vi found with the software. I understand that need to create an access file and also had a mdl file which is name after it.(I had created them). Looking at the example given, I would like to add a few more variables, to be exact 6 more variables(therefore i would have 6 colum in my access file rite?). From the "connection information" the help information shows that it contain an 1D array of DB tools colum. ctl and also a cluster of 4 elements. the link to the access file, LabVIEW.udl shows that it restrict the colum in the access file.eg it has only stringcol,intcol,doublecol. I need to add more colum but cant add just like tt.
    qn1: How to i add insert more varibles into the database so that it will apprears in access.
    qn2: I cant drag and insert the "connection information" just to have more input. how do i do it?
    qn3: where can i edit the info so that i can add more cluster into the access? when i drag out the input turn greyish.

  • Problem Creating JMS Queue Tables

    Oracle 9.2.0.1
    Help Please.
    I'm running into problems trying to create a JMS message queue table. following an example in the Oracle9ias containers for j2ee guide chapter 7. i've created a user and granted execute on sys.dbms_aqadm, sys.dbms_aq,
    sys.dbms_aqin and sys.dbms_aqjms.
    I log into SQL Plus as system with sysbda privilege.
    and attempt to create a table using
    DBMS_AQADM.CREATE_QUEUE_TABLE(
    Queue_table          => 'QTque',
    Queue_payload_type     => 'SYS.AQ$_JMS_STREAM_MESSAGE',
    multiple_consumers     => false);
    but SQL Plus responds with an error saying: unknown command beginning 'DBMS_AQADM...' rest of line ignored.
    is this a problem with my system administrator privileges
    I've given it DBA and AQ_ADMINISTRATOR_ROLE.
    In searching for a way around my problem I discovered you can easily create queue tables in the Advanced Queues section of enterprise manager. Problem doing it this way is a can't figure out how to specify payload type. If I select object I can't see how I can then specify the
    SYS.AQ$_JMS_STREAM_MESSAGE type I require.
    Any Tips appreciated.
    Gary.

    try to execute:
    BEGIN
    DBMS_AQADM.CREATE_QUEUE_TABLE(
    Queue_table => 'QTque',
    Queue_payload_type => 'SYS.AQ$_JMS_STREAM_MESSAGE',
    multiple_consumers => false);
    END;
    Regards,
    Alexei

  • Problems passing a nested table or Varray as a parameter

    Hi,
    could some one please show me the code for passing a varray or a table as a parameter in a PL/SQL function or procedure.
    I have tried a number of ways but am not getting anywhere fast. A small bit of sample code that shows a function that takes a table/varray as a parameter and uses it to do something, and code also for the method that calls this function which demonstrates how the table/varray is created and passed.
    I have a good idea how I think this should be done but cant get it to work in practice.
    Thanks and happy new year!

    sql >> CREATE OR REPLACE TYPE t_listachar
    2 AS TABLE OF VARCHAR2(100)
    3 /
    Type created.
    sql >> CREATE OR REPLACE PROCEDURE prcl_nested
    2 (
    3 p_Array IN t_ListaChar
    4 )
    5 IS
    6 BEGIN
    7 --
    8 FOR i IN p_Array.FIRST .. p_Array.LAST LOOP
    9 --
    10 dbms_output.put_line('p_Array('||i||'): '||p_Array(i)) ;
    11 --
    12 END LOOP ;
    13 --
    14 END ;
    15 /
    Procedure created.
    sql >> DECLARE
    2 --
    3 t_Array t_ListaChar := t_ListaChar('1','2','3','4','5') ;
    4 --
    5 BEGIN
    6 --
    7 prcl_nested(t_Array) ;
    8 --
    9 END ;
    10 /
    p_Array(1): 1
    p_Array(2): 2
    p_Array(3): 3
    p_Array(4): 4
    p_Array(5): 5
    PL/SQL procedure successfully completed.

  • How to create a nested table

    i want the syntax that by i can create a table in a cell of another table and how to select data from the parent table

    http://www.psoug.org/reference/nested_tab.html

  • Problem creating User Defined Table

    I am using C# and SBO 6.5
    Error Code: -1120
    Error Message: "The Mete Data for this object cannot be updated,\nsince it's ref count is bigger then 0."
    SAPbobsCOM.UserTablesMD m;
                        m = (SAPbobsCOM.UserTablesMD)
                                  frmMain.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);
    if (m.GetByKey("CBtr")==false)
    m.TableName="CBtr";
                                  m.TableDescription = "TEST";
    fieldadded =m.Add();
    if (fieldadded !=0)
    frmMain.oCompany.GetLastError(out oErrorCode,out oError);
    Any help is appreciated.
    Thanks,
    Gopal

    Hi Gopal,
    Please note that GetByKey on a meta data object already makes it necessary to release the object (in your case "m").
    In general you should use .NET's ReleaseCOMObject (see here:
    SBO-SDK Consult : Releasing COM Object in .NET) to get rid of the "reference", but note that you most likely will have to set the object variable to null.
    Alternatively setting the variable to null + a call to GC.Collect() might could do the trick, but GC.Collect() apparently works asynchronously! So, the COM object might not really have been released yet when you try to reuse the variable. GC.WaitForPendingFinalizers might work better.
    Regards,
    Frank

  • Problem creating Allocation Table with Reference to a PO

    Dear Folks,
    I am having problems creating an allocation table with reference to a PO in T-code WA01.
    I read the SAP help that some prerequisites need to exist:
    ==> You can only reference order items flagged as being relevant to a stock split (the Allocation table relevant indicator in the additional item data).
    Can anyone advice me where to find this stock split indicator?
    Also, can anyone advice me how to reuse an allocation table? For example, I had previously created an allocation table with many articles and various allocation rules. I already generated follow on documents for this table.
    Say after 2 weeks, I have the similar requirements that I can make use of the same table, only with minor adjustments to the quantity. How do I create a new allocation table using the existing allocation table data?
    Thanks and Regards
    Junwen

    Any idea please?
    thanks

  • Querying Nested Table......

    Hi,
    I am new to this nested table topic, I am facing problem in querying nested table. Actually i had created a table which consists of details regarding Applications and the platforms. As an application can run on more than one platform i had created a nested table for platform.
    CREATE OR REPLACE TYPE TY_PLATFORM AS OBJECT
    (           VC_PLATFORM VARCHAR2(64)          );
    CREATE OR REPLACE TYPE NT_TY_PLATFORM AS TABLE OF TY_PLATFORM;
    I am using this nested table in the main table application:
    CREATE TABLE T_APPLICATION
    ( N_APPLICATION_ID NUMBER(32,6),
         VC_APPLICATION_NAME VARCHAR2(160),
    CL_NT_PLATFORM NT_TY_PLATFORM )
    NESTED TABLE CL_NT_PLATFORM STORE AS CL_NT_PLATFORM_TAB
    The table contains the data like this(Just for example):
    N_APPLICATION_ID VC_APPLICATION_NAME PLATFORM
    1 ABC Unix, Windows
    2 DEF Unix, MVS
    3 GHI Unix, Windows
    4 JKL Unix, Windows, MVS
    I have created the scripts like this...
    INSERT INTO T_APPLICATION(N_APPLICATION_ID, VC_APPLICATION_NAME) VALUES(1,'ABC');
    Like that for all applications...
    UPDATE T_APPLICATION SET CL_NT_PLATFORM=NT_TY_PLATFORM(TY_PLATFORM('Unix'),TY_PLATFORM('Windows')) WHERE N_ACCESS_NUMBER=1;
    Like that for all applications.....
    After creation i had queried
    SQL> select t.n_application_id from t_application t,table(cl_nt_platform)p
    2 where p.vc_platform='Unix' and p.vc_platform='Windows' and p.vc_platform!='MVS';
    no rows selected
    Actually i want the application list which run on unix and windows platform but not MVS
    It want the result like this:
    T.N_APPLICATION_ID
    1
    2
    but it is returning no rows selected.......
    Please help me......
    Thanks in advance.....

    Wrong forum my friend. This forum is for XML DB related issues, and while we use nested tables, we never have to worry about those nasty objects that were generated by XML Schema registration :)...
    I think you need...
    Objects

  • Inserting Data into nested table

    I am exploring the differences between OBJECT & RECORD.
    As i am still in process of learning, I found that both are structures which basically groups elements of different datatypes or columns of different datatypes, one is used in SQL and other is used in PL/SQL, please correct me if I am wrong in my understanding.
    Below i am trying to insert data into an table of type object but i am unsuccessful can you please help.
    CREATE OR REPLACE type sam as OBJECT
    v1 NUMBER,
    v2 VARCHAR2(20 CHAR)
    ---Nested Table---
    create or replace type t_sam as table of sam;
    --Inserting data----
    insert into table(t_sam) values(sam(10,'Dsouza'));
    Error Message:
    Error starting at line 22 in command:
    insert into table(t_sam) values(sam(10,'Dsouza'))
    Error at Command Line:22 Column:13
    Error report:
    SQL Error: ORA-00903: invalid table name
    00903. 00000 -  "invalid table name"
    *Cause:   
    *Action:

    Ariean wrote:
    So only purpose of equivalent SQL types concept of nested tables is to use them as one of the data types while defining an actual table?
    Sort of - you can definitely use them for more than just "defining an actual table". (I'm fairly certain you could pass a nested table into a procedure, for example - try it, though - I'm not 100% sure on that - it just "makes sense". If you can define a type, you can use it, pass it around, whatever.).
    Ariean wrote:
    And that nested table could be a record in SQL or an Object in PLSQL or just simple datatype(number,varchar etc)?
    Nested tables are just like any other custom data type. You can create a nested table of other data types. You can create a custom data type of nested tables.
    It could get stupidly .. er, stupid O_0
    CREATE TYPE o_myobj1 AS object ( id1   number, cdate1  date );
    CREATE TYPE t_mytype1 AS table of o_myobj1;
    CREATE TYPE o_myobj2 AS object ( id2   number,  dumb  t_mytype1 );
    CREATE TYPE t_dumber AS table of o_myobj2;
    O_0
    Ok, my brain's starting to hurt - I hope you get the idea
    Ariean wrote:
    Secondly is my understanding correct about OBJECT & RECORD?
    I can't think of any benefit of describing it another way.

  • Trigger how to get new and old value for nested table column?

    Hi,
    I have created a nested table based on the following details:
    CREATE TYPE typ_item AS OBJECT --create object
    (prodid NUMBER(5),
    price NUMBER(7,2) )
    CREATE TYPE typ_item_nst -- define nested table type
    AS TABLE OF typ_item
    CREATE TABLE pOrder ( -- create database table
    ordid NUMBER(5),
    supplier NUMBER(5),
    requester NUMBER(4),
    ordered DATE,
    items typ_item_nst)
    NESTED TABLE items STORE AS item_stor_tab
    INSERT INTO pOrder
    VALUES (800, 80, 8000, sysdate,
    typ_item_nst (typ_item (88, 888)));
    Now I would like to create a trigger on table pOrder for after insert or update or delete
    and I would like to track the new and old value for the columns inside nested table.
    Can anybody direct me how to do it?
    I would like to know the sytax for it like:
    declare
    x number;
    begin
    x := :new.nestedtablecolumn;--how to get the new and old value from nested table columns
    end;
    Hope my question is clear.
    Thanks,
    Lavan

    Hi,
    Try like this:
    CREATE OR REPLACE TRIGGER PORDER_I
    BEFORE INSERT
    ON PORDER
    REFERENCING OLD AS old NEW AS new
    FOR EACH ROW
    DECLARE
      items_new typ_item_nst;
      ordid_NEW NUMBER;
    BEGIN
    FOR i IN :new.items.FIRST .. :new.items.LAST LOOP -- For first to last element
      DBMS_OUTPUT.PUT_LINE(':new.items(' || I || ').prodid: ' || :new.items(I).prodid );
      DBMS_OUTPUT.PUT_LINE(':new.items(' || I || ').price:  ' || :new.items(I).price );
    END LOOP;
    END;Regards,
    Peter

  • Multi-level nested tables for repeatable XML Elements

    Hi there,
    Suppose we have a XML Schema „ASchema“ like this (XMLDB schema annotations are left out for simplicity):
    <xs:schema xmlns:xs=" .... " />
    <xs:element name=“A“>
         <xs:complexType>
              <xs:sequence>
                   <xs:element name=“B“ maxOccurs=“unbounded“/>
                        <xs:complexType>
                             <xs:sequence>
                                  <xs:element name = “C“ maxOccurs=“unbounded“/>
                             </xs:sequence>
                        </xs:complexType>
                   </xs:element>
              </xs:sequence>
         </xs:complexType>
    </xs:element>
    </xs:schema>
    After registering this schema in Oracle, I can define a table like this:
    CREATE TABLE ATable
    id NUMBER,
    doc XMLTYPE
    XMLTYPE COLUMN doc
    XMLSCHEMA “ASchema“ ELEMENT “A“
    VARARRAY doc.“XMLDATA“.“B“ STORE AS TABLE “BTable“
    ((PRIMARY KEY (NESTED_TABLE_ID, SYS_NC_ARRAY_INDEX$)) ORGANIZATION INDEX)
    This creates a nested table "BTable" within the table "ATable". So far so good, I can use this nested table to gain faster access on every possible subelement of Element B when I set an appropriate index.
    I now want to create another nested table for element “C“ like this:
    DROP TABLE ATable;
    CREATE TABLE ATable
    id NUMBER,
    doc XMLTYPE
    XMLTYPE COLUMN doc
    XMLSCHEMA “ASchema“ ELEMENT “A“
    VARARRAY doc.“XMLDATA“.“B“ STORE AS TABLE “BTable“
    ((PRIMARY KEY (NESTED_TABLE_ID, SYS_NC_ARRAY_INDEX$)) ORGANIZATION INDEX)
    VARARRAY doc.“XMLDATA“.“B“.“C“ STORE AS TABLE “CTable“
    ((PRIMARY KEY (NESTED_TABLE_ID, SYS_NC_ARRAY_INDEX$)) ORGANIZATION INDEX)
    But this statement fails with the error message something like „ ... no such attribute ... „
    And here's my question: is it possible to create nested tables for repeatable XML Elements that are subelements of other repeatable XML Elements ? And if so, how can I do it ?
    Thank you very much in advance
    Jan

    Found a (partial) solution myself:
    If you add the attribute xdb:storeVarrayAsTable="true" to the root element of the XML schema, Oracle XMLDB generates nested tables for all repeatable XML Elements while registering the XML schema.
    Unfortunately, the names of these nested tables are system-generated, hence it's a bit uncomfortable to set indices on them. You can find out the names of these nested tables as follows:
    select table_name, parent_table_name, parent_table_column from user_nested_tables;
    Further information on that subject is supplied in the following thread:
    Re: default tables for elements with maxoccurs > 1
    It would be nice if there was a way to name the generated nested tables via appropriate XMLDB schema annotations.
    regards
    Jan

Maybe you are looking for