How does a record type and table type works

Hi,
How a record type and table type work for the ref cursor,
below i m giving an example but its giving me errors
can any one help me for this?
declare
type empcurtyp is ref cursor;
type rectype is record (veid t.emp_id%type, vename t.ename%type);
TYPE tabtype IS TABLE OF rectype;
empcv empcurtyp;
vtab tabtype;
begin
open empcv for select emp_id,ename from t;
loop
fetch empcv into vtab;
     exit when empcv%notfound;
     dbms_output.put_line(vtab.vename||vtab.veid);
end loop;
close empcv;
end;
here we hav table t and i m taking only two fields of the table t which r emp_id and ename.

Hi,
What errors are you getting with this? From experience you don't need a loop to put the records into the ref cursor its usually done on block.
HTHS
L :-)

Similar Messages

  • Calling Oracle Stored proc with record type and table Type

    I have a oracle SP which takes record type and table Type which are used for order management.
    Is there anay way to populate parameters with these datatypes and call the stored procedure using ODP.NET?
    Please help.
    Thanks in advance

    Hi,
    ODP supports associative arrays and REF Cursors. There is no support for PLSQL table of records.
    Jenny

  • How could I retrieve metadata about Array Type and Table Type?

    I use DatabaseMetaData.getUDTs() method for obtain metadata about Object Types, but this method doesn't work with Array Type and Table Type.

    JJ,
    Go into the diagrams of the DBTools List Columns and DBTools Get Properties respectively. When you inspect this diagram, you will see the raw ActiveX properties and methods called to get the size information. The value of -1 means the requested recordset is already closed. This is the sort of thing that is controled by the driver (ODBC, OLE DB, Jet, etc) you are using. Notice that you can right click on the property and invoke nodes and get more information about these specific items directly from the ADO online help.
    Crystal

  • Difference between line type and table type

    hi,
    can any one explain the difference between line type and table type . and how to declare a internal table and work area in BSP's

    hi,
    Go through this blog, this might help you.
    /people/tomas.altman/blog/2004/12/13/sdn-blog-how-to-do-internal-tables-in-bsp
    People who have worked with ABAP for a while sometimes forget that the internal table concept is rather different than what exists in most programming languages. It is very powerful, but at the same time can be confusing.
    In SAP it is possible to have a table which is the rows and a headerline which is the working area or structure which can then be commited to the table.
    With a BSP, if we try to create an internal table within the BSP event or layout we will get the following error: mso-bidi-
                            "InternalTableX" is not an internal table - the "OCCURS n" specification is mso-bidi- missing.
    class="MsoNormal"><![if !supportEmptyParas]>The problem we are seeing as an inconsistency has to do with the difference between classic ABAP and ABAP Objects. When SAP introduced ABAP Objects they decided to clean up some of the legacy syntax and create stricter rules. However they didn't want to break the millions of line of code that already existed, so they only implemented these stricter checks when OO is being used. Therefore you can declare a table with a header line in a regular ABAP program or Function Module but you can't have one with a header line in OO.
    Because everything in BSP generates ABAP OO classes behind the scenes, you get these same stricter syntax checks. My suggestion is that you have a look in the on-line help at the section on ABAP Objects and always follow the newer syntax rules even when writing classic ABAP programs.
    In a BSP when we need to work with a table we must always do the following:
    1, in the Types definitions create a structure:
                            types : begin of ts_reclist,
    mso-bidi-        style='mso-tab-count:2'>                            receiver type somlreci1-receiver,
    mso-bidi-        style='mso-tab-count:2'>                 style='mso-tab-count: 1'>             rec_type type somlreci1-rec_type,
    mso-bidi-         style='mso-tab-count:2'>                            end of ts_reclist.
    mso-bidi- <![if !supportEmptyParas]> <![endif]>
    but we must remember this is only a structure definition and we cannot store anything in it, although we can use it elsewhere as a definition for Structures(WorkAreas)
    2, in our Types definitions (this is the best place for this one as we can then access it from many areas without having to create it locally) so in the Types definitions we must create a TableType:
    class="MsoNormal">                         types : tt_reclist type table of ts_reclist.
    class="MsoNormal"><![if !supportEmptyParas]> <![endif]> this TableType is our table definition and again we cannot store anything in it, but we can use it elsewhere as a definition for InternalTables
    3, now that you have laid the foundations you can build and in the event handler, it is now simply a case of creating the InternalTable based upon the Table definition:
                           data: t_reclist type tt_reclist.
    and creating the structure based upon the structure definiton:
    <![if !supportEmptyParas]>   <![endif]>                         data: s_reclist type ts_reclist.
    as described above, the structure becomes the work area and this is where you assign new values for elements of the table eg:<![endif]>
                            s_reclist-receiver = '[email protected]'.   "<-- change address
    mso-bidi- <![if !supportEmptyParas]> <![endif]>
    mso-bidi-                         s_reclist-rec_type = 'U'.
    and then once the data is in the elements of the structure, the structure can be appended to the internal table as follows: class="MsoNormal">
                            append s_reclist to t_reclist.
    <![if !supportEmptyParas]> <![endif]>
    the internal table will then be readable for the ABAP function and can be applied for example as follows: class="style1">           style='mso-tab-count:1; font-family: "Courier New", Courier, mono;'>          
    class="style1">CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
                            EXPORTING
    style='mso-tab-count:2'>                                    document_data = docdata
    style='mso-tab-count:2'>                                    DOCUMENT_TYPE = 'RAW'
    style='mso-tab-count:2'>                                    PUT_IN_OUTBOX = 'X'
    style='mso-tab-count:2'>                                    COMMIT_WORK = 'X' "used from rel.6.10
                            TABLES
    mso-bidi-font-size: style='mso-tab-count:2'>                                    receivers = t_reclist
    class="style1"> <![if !supportEmptyParas]>   <![endif]>
    <![if !supportEmptyParas]>F inally, a comment from Thomas Jung,
    <![if !supportEmptyParas]> “when defining my work area for an internal table I like to use the like line of statement. That way if I change the structure of my table type, I know that my work area will still be OK. Second, your types and table types don't have to just be declared in your code. You can create a table type in the data dictionary and use it across multiple programs(also great for method and function parameters). I really push hard for the other developers at my company to use the Data Dictionary Types more and more.”
    Hope this helps, Do reward.

  • Purpose of Row type, line type and Table Type..

    Hi All,
    Just I’m started working with OOABAP. Whenever I open some structures, most of the components in the structures have the below three words. What is the exact difference b/w the below words. What is purpose those?
    Row type, line type
    Table type:
    Please let me know.

    hi,
    Line Type
    The line type of an internal table can be any data type. The data type of an internal table is normally a structure. Each component of the structure is a column in the internal table. However, the line type may also be elementary or another internal table.
    Table type
    The table type determines how ABAP will access individual table entries. Internal tables can be divided into three types:
    Standard tables have an internal linear index. From a particular size upwards, the indexes of internal tables are administered as trees. In this case, the index administration overhead increases in logarithmic and not linear relation to the number of lines. The system can access records either by using the table index or the key. The response time for key access is proportional to the number of entries in the table. The key of a standard table is always non-unique. You cannot specify a unique key. This means that standard tables can always be filled very quickly, since the system does not have to check whether there are already existing entries.
    Sorted tables are always saved sorted by the key. They also have an internal index. The system can access records either by using the table index or the key. The response time for key access is logarithmically proportional to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique or non-unique. When you define the table, you must specify whether the key is to be UNIQUE or NON-UNIQUE. Standard tables and sorted tables are known generically as index tables.
    Hashed tables have no linear index. You can only access a hashed table using its key. The response time is independent of the number of table entries, and is constant, since the system access the table entries using a hash algorithm. The key of a hashed table must be unique. When you define the table, you must specify the key as UNIQUE.
    The key identifies table rows. There are two kinds of key for internal tables - the standard key and a user-defined key. You can specify whether the key should be UNIQUE or NON-UNIQUE. Internal tables with a unique key cannot contain duplicate entries. The uniqueness depends on the table access method.
    At tables with structured row type, the standard key is formed from all character-type columns of the internal table. If a table has an elementary line type, the default key is the entire line. The default key of an internal table whose line type is an internal table, the default key is empty. At tables with non-structured row type, the standard key consists of the entire row. If the row type is also a table, an empty key is defined.
    The user-defined key can contain any columns of the internal table that are no internal table themselves, and do not contain internal tables. References are allowed as table keys. Internal tables with a user-defined key are called key tables. When you define the key, the sequence of the key fields is significant. You should remember this, for example, if you intend to sort the table according to the key.
    Internal tables are always completely specified regarding row type, key and access type
    Hope this helps.

  • Urgent : How to modify the line type and table type

    I am working on ALV Grid Control, i need to know how to modify the line type values to table type.
                 ls_celltab-fieldname = 'ZSAVINGS '.
                 ls_celltab-style = l_mode.
            INSERT ls_celltab INTO TABLE pt_celltab.
    Here ls_celltab is line type and pt_celltab is table type.
    Please give me the suggestion ASAP.
    C.Bharath Kumar

    Hi,
    Here is the example
    DATA: BEGIN OF LINE,
            LAND(3)  TYPE C,
            NAME(10) TYPE C,
            AGE      TYPE I,
            WEIGHT   TYPE P DECIMALS 2,
          END OF LINE.
    DATA ITAB LIKE SORTED TABLE OF LINE
              WITH NON-UNIQUE KEY LAND NAME AGE WEIGHT.
    LINE-LAND = 'G'.   LINE-NAME   = 'Hans'.
    LINE-AGE  = 20.    LINE-WEIGHT = '80.00'.
    INSERT LINE INTO TABLE ITAB.
    LINE-LAND = 'USA'. LINE-NAME   = 'Nancy'.
    LINE-AGE  = 35.    LINE-WEIGHT = '45.00'.
    INSERT LINE INTO TABLE ITAB.
    Regards
    Sudheer

  • How to handle plsql Object and Table type inside BPEL

    Hi All,
    I have a procedure with 5 IN and 4 OUT parameters. Out of 4, One is Object type and remaining 3 are Table type. Now in my bpel, i am calling this proc from DB Adapter. The DB Adapter wizard created XSD with proper structure. But when i am testing this i am not getting these out parameters values in the payload of Invoke DBAdapter activity. I am neither getting errors nor output.
    What could be the issue.?
    Thanks in advance,
    Sudheer

    Arik,
    JDev is not creating any wrapper packages as such. It simply created a XSD with same as my procedure name.
    My XSD looks like this...
    <element name="OutputParameters">
    <complexType>
    <sequence>
    <element name="P_OBJ_H_INFO_O" type="db:APPS.H_OBJ_TYPE" db:index="6" db:type="Struct" minOccurs="0" nillable="true"/>
    <element name="P_TAB_L_INFO_O" type="db:APPS.L_TAB_TYPE" db:index="7" db:type="Array" minOccurs="0" nillable="true"/>
    <element name="P_TAB_M_INFO_O" type="db:APPS.M_TAB_TYPE" db:index="8" db:type="Array" minOccurs="0" nillable="true"/>
    <element name="P_TAB_A_INFO_O" type="db:APPS.A_TAB_TYPE" db:index="9" db:type="Array" minOccurs="0" nillable="true"/>
    </sequence>
    </complexType>
    </element>
    And again the 3 table types internally referring object types.
    Thanks for reply. Awaiting response...
    Sudheer

  • How does FDS Data syncronization and change tracking works? example needed

    Hi All,
    I found the FDS feature of detecting the change in data and
    only updating that particular change to the server-side data.
    Could you point out some good implemented examples or
    tutorial. I am not able to find one...........
    Also point out some references/examples on how data
    syncronization works with an example..........
    Thanks in Advance,
    Vijay Karthik

    Hi HustLiliAn,
    Thank you very much for you quick reply. I have to say sorry that my code is only partially belonging to me so I cannot distribute all of them, beg your understanding
    To overcome the delay, I open both Tx and Rx session at the beginning of the code so I don't need to initial and abort session before and after using respectively. It could save a lot of time (I measure the same delay as you shown). I read from WBX application notes (http://files.ettus.com/uhd_docs/manual/html/dboards.html) that if the system is working in the duplex mode, then antenna TX/RX is using for transmission and RX2 is using for reception. I simply tested it and it seems true.
    Since two antennas are working concurrently, the receiving antenna (RX2) can receive packet even it is sent by TX/RX. My problem is, in software level I have used the if structure to make transmission and reception work successively, RX2 can still receive signal sent by TX/RX. That is the real problem. Probably we can write some compensation VI which we can remove it by using the transmitted signal, but I still want to know is there any official solution for it.
    BTW, I use the modulation toolkit. Its demodulation VI is also quite slow.
    Thank you for your reading. I am not a native English speaker, so if my post make you confuse, please let me know and I would like to elaborate it again.

  • Defining Record and Table Types

    Is there a good tutorial out there somewhere that provides good examples on how to define and work with Record and Table Types? How to define and work with an entire record or table as opposed to just a variable?
    For instance- I'd like to create a cursor of records from a table, loop through each record to examine variable values, and in some instances insert those entire records into another table.
    Thanks in advance for any suggestions.

    Oracle documentation is excellent (Lots of live examples that can be cutNpaste) place to start.
    http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/05_colls.htm
    Is there any thing specific you are looking for?
    vr,
    Sudhakar B.

  • Definitions of record and table type

    I’m confused with the definition of record and table type. Below is my understanding, Please correct me if anything wrong. Thanks in advance!
    Record type can only hold one record with multiple fields.
    Table type is an array (multiple records) with only one field
    Table type defined with %rowtype (table of records) is an array of multiple records with multiple fields.

    I am not sure that I understand what you are asking. I have not heard the term table type before.
    However, I think a record type is more closely aligned to the %rowtype declaration. Maybe a collection is what you are looking for with the term table type.
    From the Oracle 10g documentation:
    %ROWTYPE
    In PL/SQL, records are used to group data. A record consists of a number of related fields in which data values can be stored. The %ROWTYPE attribute provides a record type that represents a row in a table. The record can store an entire row of data selected from the table or fetched from a cursor or cursor variable.
    Columns in a row and corresponding fields in a record have the same names and datatypes. In the example below, you declare a record named dept_rec. Its fields have the same names and datatypes as the columns in the dept table.
    DECLARE
    dept_rec dept%ROWTYPE; -- declare record variable

  • Error while doing Bulk Collect to a table type

    I'm using a Table type to accumulate resultset from a loop and finally return the records in the table type as a ref cursor to the front end.
    But when I'm using Bult collect to insert into the table type object it keeps throwing an error
    'PLS-00597: expression 'TAB_CALENDAR_AVAIL_RESULTSET' in the INTO list is of wrong type'. Can someone help me to let me know what could be the reason for this error. I'm not able to proceed further, please help.
    Here is the code.
    CREATE OR REPLACE PACKAGE hotel
    AS
    TYPE calendar_cursor IS REF CURSOR;
    TYPE type_calendar_avail is RECORD(
    HOTEL_ID AVAILABILITY_CALENDAR.hotel_id%TYPE,--varchar2(4), --AVAILABILITY_CALENDAR.hotel_id%TYPE,
    AVAIL_DATE AVAILABILITY_CALENDAR.AVAIL_DATE%TYPE ,
    TOTAL_COUNT number
    TYPE type_calendar_avail_resultset IS TABLE OF type_calendar_avail;
    tab_calendar_avail_resultset type_calendar_avail_resultset ; -- declare variable of type type_calendar_avail_resultset
    PROCEDURE sp_get_calendar_results (
    sallhotelswithavaildate VARCHAR2,
    ilengthofstay NUMBER,
    sorcowner VARCHAR2,
    all_unittypes VARCHAR2, --DBMS_SQL.VARCHAR2S
    calendar_resultset OUT calendar_cursor
         -- tab_calendar_avail_resultset out type_calendar_avail_resultset
    PROCEDURE sp_get_calendar_results (
    sallhotelswithavaildate VARCHAR2,
    ilengthofstay NUMBER,
    -- ivariant NUMBER,
    sorcowner VARCHAR2,
    all_unittypes VARCHAR2, --DBMS_SQL.VARCHAR2S
    calendar_resultset OUT calendar_cursor
    AS
    sbuf VARCHAR2 (200);
    sepr VARCHAR2 (1);
    shotelwithdate VARCHAR2 (200);
    shotelid VARCHAR2 (10);
    savaildate VARCHAR2 (8);
    sactualavaildate VARCHAR2 (8);
    pos NUMBER;
    istart NUMBER;
    sstartdate VARCHAR2 (8);
    senddate VARCHAR2 (8);
    squery VARCHAR2 (32767) := '';
    sunittypecond VARCHAR2 (500) := '';
    sunitdesccond VARCHAR2 (500) := '';
    v_unit_cond a_unit_cond;
    tempunitcond VARCHAR2 (50) := '';
    BEGIN
    istart := 1;
    LOOP
    tempunitcond := hotel.stringtokenizer (all_unittypes, istart, '|');
    IF tempunitcond IS NOT NULL
    THEN
    v_unit_cond (istart) := tempunitcond;
    istart := istart + 1;
    END IF;
    EXIT WHEN tempunitcond IS NULL;
    END LOOP;
    sunitdesccond := hotel.get_unit_description_cond (v_unit_cond);
    DBMS_OUTPUT.put_line ('unit description : ' || sunitdesccond);
    sbuf := sallhotelswithavaildate;
    sepr := '|';
    istart := 1;
    LOOP
    shotelwithdate := hotel.stringtokenizer (sbuf, istart, sepr);
    EXIT WHEN shotelwithdate IS NULL;
    shotelid :=
    SUBSTR (shotelwithdate, 1, INSTR (shotelwithdate, ',') - 1);
    savaildate :=
    SUBSTR (shotelwithdate, INSTR (shotelwithdate, ',') + 1);
    squery :=
    ' SELECT MIN (ad.avail_date) '
    || ' FROM wvo_fonres.fpavail_daily ad'
    || ' WHERE ad.hotel_id = '
    || shotelid
    || ' AND ad.days_left >= '
    || ilengthofstay
    || ' AND ad.avail_date >= '
    || savaildate;
    IF UPPER (sorcowner) = 'N'
    THEN
    squery :=
    squery
    || ' AND ad.ORC_TYPE != ''R'' and ad.ORC_TYPE != ''P'' and ad.ORC_TYPE != ''E'' ';
    END IF;
    squery := squery || ' AND ( ' || sunitdesccond || ') ';
    EXECUTE IMMEDIATE squery
    INTO sactualavaildate;
    DBMS_OUTPUT.put_line ('Actual available Date: ' || sactualavaildate);
    hotel.sp_get_startdate_enddate (sactualavaildate,
    --ivariant,
    sstartdate,
    senddate
    sunittypecond := hotel.get_unittype_cond (v_unit_cond, sorcowner);
    -- execute immediate
    squery :=
    'select HOTEL_ID, AVAIL_DATE, ' || sunittypecond || ' AS TOTAL_COUNT '
    || ' FROM AVAILABILITY_CALENDAR A '
    || 'WHERE '
    || 'AVAIL_DATE >= '''
    || sstartdate
    || ''' '
    || 'AND '
    || 'AVAIL_DATE <= '''
    || senddate
    || ''' '
    ||'AND '
    || 'A.HOTEL_ID IN ('
    || shotelid
    || ') '
    || 'AND ('
    || sunittypecond
    || '> 0) '
    || -- where total available count of unit type is greater than 0
    ' ORDER BY AVAIL_DATE'; --order clause
         open calendar_resultset for squery;
         fetch calendar_resultset BULK COLLECT INTO tab_calendar_avail_resultset;
    istart := istart + 1;
    END LOOP;
    COMMIT;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.put_line
    (SQLERRM (SQLCODE));
    RAISE;
    END sp_get_calendar_results;
    END hotel;
    /

    1. put tags [co[/b][b]de] and [co[/b][b]de] around your code, so it's readable
    B. what does "hotel.get_unittype_cond (v_unit_cond, sorcowner)" actually retun?
    and third, try this for the array declaration:
    tab_calendar_avail_resultset type_calendar_avail_resultset := type_calendar_avail_resultset ; () ;

  • How does system automatically picks up document type when you enter INV?

    1.How does system automatically picks up document type when you enter Invoice?
    2.What is Algorithms? Where is it used?
    3.What is the use of Customer Ledger Inquiry?

    The document type is hard coded by the system. Look at UDC table 00/DT for the document types in your system. Notice that some of those are marked as hard coded/reserved by JDE. You may wish to dowload the Accounts Receivable manual and read that to learn more about the document types.
    Not sure what you mean by algorithm, unless you are looking for how the system determines what document type to assign on invoice entry.
    These comments apply to accounts receivable and to JDE World, since you posted in the JDE World forum and are talking about the customer ledger inquiry. If you are in Enterprise One and asking about Accounts Payable, then this reply can be ignored (though Enterprise One works pretty similar to World in this respect).
    What is the use of the Customer Ledger Inquiry. To view accounts receivable detail history for a given customer, viewing on line. Whomever works in the accounts receivable department will likely use the Customer Ledger Inquiry quite a bit.
    Hope this helps a bit.
    John Dickey

  • How can we relate c and x  types in ABAP

    hi all,
    I would like to know how we could relate c type and x type in ABAP.
    In terms of size specification.
    Thank you all
    prasad.

    Hi Prasad,
    Consider the following code snippet -
    data : char type c,
           hexa type x.
    Now, both these variables are of 1 byte each. However, they store different kinds of data, so we have -
    hexa = '41'.
    write : hexa to char.
    write: char , hexa.
    hexa is going to store the hexadecimal number 41. (the decimal equivalent is 65). The first write statement does the automatic type conversion. so we get the 65th ASCII character in the character variable (which is the capital A).
    Hope that helps.
    Regards,
    Anand MAndalika.

  • ST03 Export: How to export all instances and task types?

    I am exporting ST03 data using SAP GUI
    I can export data for a single task type and a single instance.Is there a way I can export the Time Profile data for all instances and all task types in a single export? Can I do a single export rather than NxM exports?
    Also, when I export to a text file, there is a header that reports the instance, data, and task type. When I export to excel file I only get the table, not the header info. Is there a way to to get the header info into the excel export?
    Is this the appropriate forum for these questions?
    Any help is appreciated.
    Thanks.
    Tim

    I moved this question to an ABAP forum. Here's the [thread|ST03 Export: How to export all instances and task types?;.
    Tim

  • Help in using record type and object type

    Hi Experts,
    I am new to object types and record types.
    I want to return the output of this query using one OUT parameter
    from the procedure using RECORD type or OBJECT type.
    with out using refcursor.
    SELECT empno,ename,sal FROM emp WHERE deptno=30;
    Let us assume the query is returning 50 records.
    I want to send those 50 records to OUT parameter using record type or object type.
    Please provide the for the requirement code using RECORD TYPE and OBJECT TYPE separately.
    Your earliest response is appreciated.
    Thanks in advance.

    Hi All,
    I have tried this.But it ising not work
    CREATE OR REPLACE PACKAGE maultiplevalues_pkg
    IS
    TYPE t_record IS RECORD
    (empno emp.empno%TYPE,
    ename emp.ename%TYPE,
    sal emp.sal%TYPE);
    V_RECORD t_record;
    TYPE t_type IS TABLE OF V_RECORD%TYPE;
    PROCEDURE maultiplevalues_pROC(p_deptno IN emp.deptno%TYPE,
    dept_result OUT t_type);
    END;
    CREATE OR REPLACE PACKAGE body maultiplevalues_pkg
    IS
    PROCEDURE maultiplevalues_pROC(p_deptno IN emp.deptno%TYPE,
    dept_result OUT t_type)
    is
    begin
    dept_result :=t_type();
    for I in(
    select EMPNO,ENAME,SAL from EMP WHERE deptno=p_deptno
    LOOP
    dept_result.extend;
    dept_result(i).empno :=i.empno;
    dept_result(i).ename :=i.ename;
    dept_result(i).sal :=i.sal;
    END LOOP;
    END;
    END;
    Please help me OUT return multiple values through single OUT variable in a procedure.
    Thanks.

Maybe you are looking for