Using RTTI in table type any

Hello,
i have table type any and i want to know in the loop for every field which type he have ,for instance for field type Date8.
what i the best way to do so , i guess that I need to use for instance cl_abap_elemdescr=>get_data_type_kind( <lv_field> ) but i dont know
how to use it and check every field in the loop ...
E.g.
loop at <lt_fields> assigning <ls_fields>
* check for every field in <ls_fields> which type he have and if the field is type date8
* handle it diffrently
endloop.
Regards
Joy

You can use Absolute Name to get the absolute type from the type descriptor.
DATA: lt_vbak TYPE STANDARD TABLE OF vbak.
DATA: lo_struct   TYPE REF TO cl_abap_structdescr,
      lt_comp     TYPE cl_abap_structdescr=>component_table,
      la_comp     LIKE LINE OF lt_comp.
lo_struct ?= cl_abap_typedescr=>describe_by_name( 'VBAK' ).
lt_comp  = lo_struct->get_components( ).
WRITE: /(30) 'Field' , (40) 'Absolute Type'.
DATA: lv_abs_name TYPE string.
LOOP AT lt_comp INTO la_comp.
  WRITE: /(30) la_comp-name, (40) la_comp-type->absolute_name.
ENDLOOP.
Regards,
Naimesh Patel

Similar Messages

  • FM Table TYPE ANY

    Hi,
    is it possible to give an FM a table with the type ANY? The table type is dynamic.
    Regards,
    Sinan

    TABLES parameters are table parameters. Table parameters are obsolete CHANGING parameters that are typed as internal standard tables with a header line. If an internal table without a header line or a table body is passed as an actual parameter to such a formal parameter, an empty header line is generated in the function module. If an internal table with a header line is used as an actual parameter, both the table body and the header line are passed to the function module. In the case of formal parameters defined with TABLES, no value transmission is possible.
    Formal parameters defined with TABLES can be replaced by formal parameters defined with CHANGING. A local work area can be created in the function module  for the internal table using the addition LIKE LINE OF itab of the DATA statement in the function module.
    So you cant use the Tables type any option.....
    Message was edited by:
            Muthurajan Ramkumar

  • Senarious for using different internal table types

    please give scenarios for  using different internal table types?

    Refer to the following.
    Internal table types
    This section describes how to define internal tables locally in a program. You can also define internal tables globally as data types in the ABAP Dictionary.
    Like all local data types in programs , you define internal tables using the TYPES statement. If you do not refer to an existing table type using the TYPE or LIKE addition, you can use the TYPES statement to construct a new local internal table in your program.
    TYPES <t> TYPE|LIKE <tabkind> OF <linetype> [WITH <key>]
    [INITIAL SIZE <n>].
    After TYPE or LIKE, there is no reference to an existing data type. Instead, the type constructor occurs:
    <tabkind> OF <linetype> [WITH <key>]
    The type constructor defines the table type <tabkind>, the line type <linetype>, and the key <key> of the internal table <t>.
    You can, if you wish, allocate an initial amount of memory to the internal table using the INITIAL SIZE addition.
    Table type
    You can specify the table type <tabkind> as follows:
    Generic table types
    INDEX TABLE
    For creating a generic table type with index access.
    ANY TABLE
    For creating a fully-generic table type.
    Data types defined using generic types can currently only be used for field symbols and for interface parameters in procedures . The generic type INDEX TABLE includes standard tables and sorted tables. These are the two table types for which index access is allowed. You cannot pass hashed tables to field symbols or interface parameters defined in this way. The generic type ANY TABLE can represent any table. You can pass tables of all three types to field symbols and interface parameters defined in this way. However, these field symbols and parameters will then only allow operations that are possible for all tables, that is, index operations are not allowed.
    Fully-Specified Table Types
    STANDARD TABLE or TABLE
    For creating standard tables.
    SORTED TABLE
    For creating sorted tables.
    HASHED TABLE
    For creating hashed tables.
    Fully-specified table types determine how the system will access the entries in the table in key operations. It uses a linear search for standard tables, a binary search for sorted tables, and a search using a hash algorithm for hashed tables.
    Line type
    For the line type <linetype>, you can specify:
    Any data type if you are using the TYPE addition. This can be a predefined ABAP type, a local type in the program, or a data type from the ABAP Dictionary. If you specify any of the generic elementary types C, N, P, or X, any attributes that you fail to specify (field length, number of decimal places) are automatically filled with the default values. You cannot specify any other generic types.
    Any data object recognized within the program at that point if you are using the LIKE addition. The line type adopts the fully-specified data type of the data object to which you refer. Except for within classes, you can still use the LIKE addition to refer to database tables and structures in the ABAP Dictionary (for compatibility reasons).
    All of the lines in the internal table have the fully-specified technical attributes of the specified data type.
    Key
    You can specify the key <key> of an internal table as follows:
    [UNIQUE|NON-UNIQUE] KEY <col1> ... <col n>
    In tables with a structured line type, all of the components <coli> belong to the key as long as they are not internal tables or references, and do not contain internal tables or references. Key fields can be nested structures. The substructures are expanded component by component when you access the table using the key. The system follows the sequence of the key fields.
    [UNIQUE|NON-UNIQUE] KEY TABLE LINE
    If a table has an elementary line type (C, D, F, I, N, P, T, X), you can define the entire line as the key. If you try this for a table whose line type is itself a table, a syntax error occurs. If a table has a structured line type, it is possible to specify the entire line as the key. However, you should remember that this is often not suitable.
    [UNIQUE|NON-UNIQUE] DEFAULT KEY
    This declares the fields of the default key as the key fields. If the table has a structured line type, the default key contains all non-numeric columns of the internal table that are not and do not contain references or internal tables. If the 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.
    Specifying a key is optional. If you do not specify a key, the system defines a table type with an arbitrary key. You can only use this to define the types of field symbols and the interface parameters of procedures . For exceptions, refer to Special Features of Standard Tables.
    The optional additions UNIQUE or NON-UNIQUE determine whether the key is to be unique or non-unique, that is, whether the table can accept duplicate entries. If you do not specify UNIQUE or NON-UNIQUE for the key, the table type is generic in this respect. As such, it can only be used for specifying types. When you specify the table type simultaneously, you must note the following restrictions:
    You cannot use the UNIQUE addition for standard tables. The system always generates the NON-UNIQUE addition automatically.
    You must always specify the UNIQUE option when you create a hashed table.
    Initial Memory Requirement
    You can specify the initial amount of main memory assigned to an internal table object when you define the data type using the following addition:
    INITIAL SIZE <n>
    This size does not belong to the data type of the internal table, and does not affect the type check. You can use the above addition to reserve memory space for <n> table lines when you declare the table object.
    When this initial area is full, the system makes twice as much extra space available up to a limit of 8KB. Further memory areas of 12KB each are then allocated.
    You can usually leave it to the system to work out the initial memory requirement. The first time you fill the table, little memory is used. The space occupied, depending on the line width, is 16 <= <n> <= 100.
    It only makes sense to specify a concrete value of <n> if you can specify a precise number of table entries when you create the table and need to allocate exactly that amount of memory (exception: Appending table lines to ranked lists). This can be particularly important for deep-structured internal tables where the inner table only has a few entries (less than 5, for example).
    To avoid excessive requests for memory, large values of <n> are treated as follows: The largest possible value of <n> is 8KB divided by the length of the line. If you specify a larger value of <n>, the system calculates a new value so that n times the line width is around 12KB.
    Examples
    TYPES: BEGIN OF LINE,
    COLUMN1 TYPE I,
    COLUMN2 TYPE I,
    COLUMN3 TYPE I,
    END OF LINE.
    TYPES ITAB TYPE SORTED TABLE OF LINE WITH UNIQUE KEY COLUMN1.
    The program defines a table type ITAB. It is a sorted table, with line type of the structure LINE and a unique key of the component COLUMN1.
    TYPES VECTOR TYPE HASHED TABLE OF I WITH UNIQUE KEY TABLE LINE.
    TYPES: BEGIN OF LINE,
    COLUMN1 TYPE I,
    COLUMN2 TYPE I,
    COLUMN3 TYPE I,
    END OF LINE.
    TYPES ITAB TYPE SORTED TABLE OF LINE WITH UNIQUE KEY COLUMN1.
    TYPES: BEGIN OF DEEPLINE,
    FIELD TYPE C,
    TABLE1 TYPE VECTOR,
    TABLE2 TYPE ITAB,
    END OF DEEPLINE.
    TYPES DEEPTABLE TYPE STANDARD TABLE OF DEEPLINE
    WITH DEFAULT KEY.
    The program defines a table type VECTOR with type hashed table, the elementary line type I and a unique key of the entire table line. The second table type is the same as in the previous example. The structure DEEPLINE contains the internal table as a component. The table type DEEPTABLE has the line type DEEPLINE. Therefore, the elements of this internal table are themselves internal tables. The key is the default key - in this case the column FIELD. The key is non-unique, since the table is a standard table.
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/content.htm

  • Working with table type any with mapping according to keys

    Hi All ,
    I have table type any with data and I need to fill structure type any according to respective  key and verify that the field is have mapping .
    i.e. I have a table <lt_itab> and I need to find the specific entry on it according to the key and the mapping .
    I guess that the best way is to give example.
    <lt_itab> -  Is type any and can have lot of entries
    lt_key  -  Is specified table with field_name and value
    lt_map  -  Table with field_name which have mapping (have unique field name in every entry of the table )from f1..fn -
    I need to fill fields in <ls_output> just if they appear in lt_map
    <ls_output> - Is structure type any that in the end should have all the data from <ls_itab> according to the mapping and the keys of the table
    <lt_itab> - table
    f1  f2  f3  f4  f5 f6
    1   2    3  4   5  6 
    5   5    4  3   8  4 
    6   9    2  5   3  5
    1   3    3  4   2  1
    lt_key  - table
    field_name   value
    f1            1
    f2            3
    lt_map  - table
    field_name
    f1
    f2
    f5
    f6
    <ls_output> - structure
    field  value
    f1  -   1
    f2  -   2
    f3  "Not in mapping so it's empty
    f4  "Not in mapping so it's empty
    f5  -   2
    f6  -   1
    <ls_output> have the field values of the last entry of <lt_itab> according to the key of f1 and f2 and according to the mapping f3 and f4 are empty
    since they are not appaer in lt_map
    Regards
    Joy

    Hi
    You have to loop fully your main table in order to get the records in according to they keys:
    LOOP AT <LT_ITAB> ASSIGNING <WT_ITAB>.
       L_KO = SPACE.
       LOOP AT LT_KEY.
            ASSIGN COMPONENT LT_KEY-FIELDNAME OF STRUCTURE <WT_ITAB> TO <FS_KEY>.
            IF <FS_KEY> NE LT_KEY-VALUE.
               L_KO = 'X'.
               EXIT.
            ENDIF.
        ENDLOOP.
        CHECK L_KO IS INITIAL.
        LOOP AT LT_MAP.
            ASSIGN COMPONENT LT_MAP-FIELDNAME OF STRUCTURE <WT_ITAB>      TO <FS_FROM>.
            ASSIGN COMPONENT LT_MAP-FIELDNAME OF STRUCTURE <WT_OUTPUT> TO <FS_TO>.
            <FS_TO> = <FS_FROM>.
        ENDLOOP.
        APPEND <WT_OUTPUT> TO <LT_OUTPUT>.
    ENDLOOP.
    Max

  • How to use FIELD-SYMBOLS with TYPE ANY?

    Hi!
    I need to write a function which gets an import string parameter containing a field name like MATNR. In this function I have to "map" this string to a real variable so that I can access the field which is represented by the string. I tried it like this but it does not work:
    FUNCTION ZTEST1.
    ""Lokale Schnittstelle:
    *"  IMPORTING
    *"     REFERENCE(I_MARA) TYPE  MARA
      DATA: FIELD_NAME(30) VALUE 'I_MARA'.
      FIELD-SYMBOLS : <FS_ANY> TYPE ANY.
      Assign (FIELD_NAME) to <FS_ANY>.
    Does not work (I guess because of 'type any')
      WRITE: <FS_ANY>-MATNR.
    ENDFUNCTION.
    How can I solve this problem?
    Thanks,
    Konrad

    This code is far from perfection...But at least it could help you to find the right track -;)
    REPORT ydummy_atg.
    DATA: w_mara TYPE STANDARD TABLE OF mara.
    START-OF-SELECTION.
      SELECT *
      INTO TABLE w_mara
      FROM mara.
      PERFORM test TABLES w_mara.
    *&      Form  test
    FORM test TABLES t_mara.
      DATA: field_name(30) VALUE 'T_MARA',
            new_line TYPE REF TO data,
            flag TYPE c,
            w_tabix TYPE sy-tabix.
      FIELD-SYMBOLS : <fs_any> TYPE ANY,
                      <l_line> TYPE ANY,
                      <l_field> TYPE ANY.
      ASSIGN (field_name) TO <fs_any>.
      CREATE DATA new_line LIKE LINE OF t_mara.
      ASSIGN new_line->* TO <l_line>.
      LOOP AT t_mara.
        MOVE t_mara TO <l_line>.
        ASSIGN COMPONENT 2 OF STRUCTURE <l_line> TO <l_field>.
        <l_field> = <l_line>.
        WRITE:/ <l_field>.
      ENDLOOP.
    ENDFORM.                    " test
    Greetings,
    Blag.

  • Modify Syntax on Internal table of type ANY TABLE

    Hi,
    I have declared one internal table which is of type ANY TABLE.
    In the Loop statement, I am trying to Modify that Internal table from WA.
    Then I am getting one Error message
    "You cannot use explicit or implicit index operations on tables with types "HASHED TABLE" or "ANY TABLE". "C_T_DATA" has the type "ANY TABLE".
    Above code I have placed in method of a corresponding Class.
    Can u please advise me on this..How to modify the Intenal table .
    Thanks and Regards,
    K.Krishna Chaitanya.

    Hi Krishna,
    the modify statement is obsolete.
    You can always LOOP AT [itab] ASSIGNING <field-symbol>.
    This makes the loop never slower, depending on the table structure faster or much faster.
    If you know the table structure at run time, you can use a field-symbol of that type. If not, you can use a field-symbol TYPE any. Then you have to assign the components to field-symbol to modify them, i.e.
    field-symbols:
      <table_line> type any,
      <matnr>        type mara-matnr.
    loop at itab assigning  <table_line>.
      assign component 'MATNR' of structure <table_line> to <matnr>.
      clear <matnr>.
    endloop.
    This technique (available more than ten years) works incredibly fast. My estimate is that if SAP would change all the old standard programs that way and use it consequently in the new ones, the whole system would be 20 % faster because myriads of unnecessary copy operations of LOOP INTO would not happen.
    Regards,
    Clemens.

  • User defined table types sometimes show up a unknown data type in Profiler

    A couple of our users have a problem when using user defined table types. Calls are made using UDTT as variables and these are then passed to a stored procedure as parameters. Sometimes the application returns a timeout. In such situations a Profiler-Trace
    shows the following:
    declare @p4 unknown
    whereas the correct trace (that is sometimes displayed) should be:
    declare @p4 dbo.ReportFilterTableType
    ReportFilterTableType is a UDTT. The users do have correct permissions for the UDTT (otherwise they would never be usable for the user). What could be the reason that the data types for the variable
    @p4 in the example are sometimes returned as unknown and at other times are returned correctly as
    ReportFilterTableType? Could this possibly be a network related issue?
    Thank you.
    Graham Goodwin Email: [email protected]

    I know this is a old post, but i am also facing the same issue that too in my production server. Did you find any workarround for this issue. Please do reply. Critical problem we are facing.
    Alka, Is your problem timeouts when passing TVP parameters, or is it that a Profiler Trace shows type "unknown" for the TVP data type name?
    If your problem is timeouts, be aware that TVPs do not have statistics so the optimizer might not be able to generate an optimal plan for non-trivial queries. Declaring a primary key or unique constraint on the table type may help since that will provide
    useful cardinality information.  You may need to resort to hints in some cases.
    I suggest you start a new thread with details of your specific situation if the information in this thread doesn't help.
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

  • Oracle Object Table Type

    I have an application that I would like to map bc4j to a object type hierarchy in the database. From reading previous otn threads I'm under the impression that Domains are not used for Oracle Table Types, just for columns based on oracle types. The thread later goes on to say that for the base type (person_typ) I would map a entity object to the table(person_table) mapped to the base type. To map all the sub-types I would create new entity objects and have PersonEO subclassed into StudentEO and EmployeeEO.
    I have done this and it's unclear to me when I subclass PersonEO as StudentEO how do I declare that StudentEO is of oracle object type student_typ?
    I'm also having problems with inserting data into the base entity obect. Here's code:
    PersonVOImpl personVo = am.getPersonVO();
    PersonVORowImpl row = (PersonVORowImpl)personVo.createRow();
    personVo.insertRow(row);
    row.setName("Mark");
    row.setPhone("911");
    am.getTransaction().commit();
    personVo.executeQuery();
    while (personVo.hasNext()){
    PersonVORowImpl personRow = (PersonVORowImpl)personVo.next();
    The data gets comitted to the db correctly but when the code hits personVo.executeQuery() I get the following error:
    oracle.jbo.domain.DataCreationException: JBO-25009: Cannot create an object of type:oracle.sql.STRUCT with value:Mark
         at oracle.jbo.domain.TypeFactory.get(TypeFactory.java:687)
         at oracle.jbo.domain.TypeFactory.getInstance(TypeFactory.java:80)
         at oracle.jbo.server.OracleSQLBuilderImpl.doLoadBulkFromResultSet(OracleSQLBuilderImpl.java:1113)
         at oracle.jbo.server.ViewRowImpl.populate(ViewRowImpl.java:2017)
         at oracle.jbo.server.ViewDefImpl.createInstanceFromResultSet(ViewDefImpl.java:1013)
         at oracle.jbo.server.ViewObjectImpl.createRowFromResultSet(ViewObjectImpl.java:2309)
         at oracle.jbo.server.ViewObjectImpl.createInstanceFromResultSet(ViewObjectImpl.java:2240)
         at oracle.jbo.server.QueryCollection.populateRow(QueryCollection.java:1698)
         at oracle.jbo.server.QueryCollection.fetch(QueryCollection.java:1552)
         at oracle.jbo.server.QueryCollection.get(QueryCollection.java:1008)
         at oracle.jbo.server.ViewRowSetImpl.getRow(ViewRowSetImpl.java:2791)
         at oracle.jbo.server.ViewRowSetIteratorImpl.doFetch(ViewRowSetIteratorImpl.java:2504)
         at oracle.jbo.server.ViewRowSetIteratorImpl.ensureRefreshed(ViewRowSetIteratorImpl.java:2368)
         at oracle.jbo.server.ViewRowSetIteratorImpl.refresh(ViewRowSetIteratorImpl.java:2569)
         at oracle.jbo.server.ViewRowSetImpl.notifyRefresh(ViewRowSetImpl.java:1641)
         at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:577)
         at oracle.jbo.server.ViewRowSetImpl.executeQueryForMasters(ViewRowSetImpl.java:611)
         at oracle.jbo.server.ViewRowSetImpl.executeQuery(ViewRowSetImpl.java:593)
         at oracle.jbo.server.ViewObjectImpl.executeQuery(ViewObjectImpl.java:2886)
         at model.testing.main(testing.java:33)
    Am I coding this correctly? I'm using jdev9032 for this. Are there any examples out there on how to correctly use bc4j with oracle object type tables?
    Thanks in advance!
    -Mark

    Here is my ddl:
    CREATE TYPE Person_typ AS OBJECT
    ( name VARCHAR2(30),
    address VARCHAR2(100)) NOT FINAL
    CREATE TABLE PERSON_TABLE OF PERSON_TYP
    I map a entity object to person_table one for one and I edit the SYS_NC_OID$ property of updateable to never.
    I then map a view object one for one to the entity object. The jbo trace I get when -Djbo.debugoutput=console is declared is the following (omitted everything before the db connected).[156] Successfully logged in
    [157] JDBCDriverVersion: 9.0.1.4.0
    [158] DatabaseProductName: Oracle
    [159] DatabaseProductVersion: Personal Oracle9i Release 9.2.0.1.0 - Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.1.0 - Production
    [160] ViewRowSetImpl's jbo.viewlink.consistent = false (0)
    [161] Column count: 3
    [162] Executing SQL in generateRefAndOID...
    [163] select a.oid, make_ref(PERSON_TABLE, a.oid) from (select /*+ NO_MERGE +*/ sys_op_guid() as oid from dual) a
    [164] OracleSQLBuilder Executing DML on: PERSON_TABLE (Insert)
    [165] INSERT INTO PERSON_TABLE(NAME,ADDRESS) VALUES (:1,:2)
    [166] BaseSQLBuilder: releaseSavepoint 'BO_SP' ignored
    [167] PersonVO notify COMMIT ...
    [168] Column count: 3
    [169] ViewObject : Created new QUERY statement
    [170] SELECT REF(PersonTable), PersonTable.NAME, PersonTable.ADDRESS FROM PERSON_TABLE PersonTable
    [171] LoadBulkFromResultSet failed (2)
    oracle.jbo.domain.DataCreationException: JBO-25009: Cannot create an object of type:oracle.sql.STRUCT with value:Mark
         java.lang.Object oracle.jbo.domain.TypeFactory.get(java.lang.Class, java.lang.Class, java.lang.Object)
              TypeFactory.java:687
         java.lang.Object oracle.jbo.domain.TypeFactory.getInstance(java.lang.Class, java.lang.Object)
              TypeFactory.java:80
         java.lang.Object[] oracle.jbo.server.OracleSQLBuilderImpl.doLoadBulkFromResultSet(oracle.jbo.server.AttributeDefImpl[], int, java.sql.ResultSet, int, oracle.jbo.server.DBTransactionImpl)
              OracleSQLBuilderImpl.java:1059
         void oracle.jbo.server.ViewRowImpl.populate(java.sql.ResultSet)
              ViewRowImpl.java:1964
         oracle.jbo.server.ViewRowImpl oracle.jbo.server.ViewDefImpl.createInstanceFromResultSet(oracle.jbo.server.ViewObjectImpl, oracle.jbo.server.QueryCollection, java.sql.ResultSet)
              ViewDefImpl.java:1019
         oracle.jbo.server.ViewRowImpl oracle.jbo.server.ViewObjectImpl.createRowFromResultSet(java.lang.Object, java.sql.ResultSet)
              ViewObjectImpl.java:2035
         oracle.jbo.server.ViewRowImpl oracle.jbo.server.ViewObjectImpl.createInstanceFromResultSet(oracle.jbo.server.QueryCollection, java.sql.ResultSet)
              ViewObjectImpl.java:1966
         oracle.jbo.server.ViewRowImpl oracle.jbo.server.QueryCollection.populateRow()
              QueryCollection.java:1395
         boolean oracle.jbo.server.QueryCollection.fetch(int)
              QueryCollection.java:1237
         java.lang.Object oracle.jbo.server.QueryCollection.get(int)
              QueryCollection.java:832
         oracle.jbo.Row oracle.jbo.server.ViewRowSetImpl.getRow(int)
              ViewRowSetImpl.java:2621
         void oracle.jbo.server.ViewRowSetIteratorImpl.doFetch(int)
              ViewRowSetIteratorImpl.java:2347
         void oracle.jbo.server.ViewRowSetIteratorImpl.ensureRefreshed()
              ViewRowSetIteratorImpl.java:2211
         void oracle.jbo.server.ViewRowSetIteratorImpl.refresh(boolean, boolean)
              ViewRowSetIteratorImpl.java:2412
         void oracle.jbo.server.ViewRowSetImpl.notifyRefresh(boolean, boolean)
              ViewRowSetImpl.java:1556
         void oracle.jbo.server.ViewRowSetImpl.execute(boolean, boolean)
              ViewRowSetImpl.java:548
         void oracle.jbo.server.ViewRowSetImpl.executeQuery()
              ViewRowSetImpl.java:564
         void oracle.jbo.server.ViewObjectImpl.executeQuery()
              ViewObjectImpl.java:2616
         void mypackage1.testing.main(java.lang.String[])
              testing.java:25
    Exception in thread main
    Process exited with exit code 1.
    Please let me know if you need more information.
    -Mark

  • Huge memory leaks in using PL/SQL tables and collections

    I have faced a very interesting problem recently.
    I use PL/SQL tables ( Type TTab is table of ... index by binary_integer; ) and collections ( Type TTab is table of ...; ) in my packages very widely. And have noticed avery strange thing Oracle does. It seems to me that there are memory leaks in PGA when I use PL/SQL tables or collections. Let me a little example.
    CREATE OR REPLACE PACKAGE rds_mdt_test IS
    TYPE TNumberList IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
    PROCEDURE test_plsql_table(cnt INTEGER);
    END rds_mdt_test;
    CREATE OR REPLACE PACKAGE BODY rds_mdt_test IS
    PROCEDURE test_plsql_table(cnt INTEGER) IS
    x TNumberList;
    BEGIN
    FOR indx IN 1 .. cnt LOOP
    x(indx) := indx;
    END LOOP;
    END;
    END rds_mdt_test;
    I run the following test code:
    BEGIN
    rds_mdt_test.test_plsql_table (1000000);
    END;
    and see that my session uses about 40M in PGA.
    If I repeat this example in the same session creating the PL/SQL table of smaller size, for instance:
    BEGIN
    rds_mdt_test.test_plsql_table (1);
    END;
    I see again that the size of used memory in PGA by my session was not decreased and still be the same.
    The same result I get if I use not PL/SQL tables, but collections or varrays.
    I have tried some techniques to make Oracle to free the memory, for instance to rewrite my procedure in the following ways:
    PROCEDURE test_plsql_table(cnt INTEGER) IS
    x TNumberList;
    BEGIN
    FOR indx IN 1 .. cnt LOOP
    x(indx) := indx;
    END LOOP;
    x.DELETE;
    END;
    or
    PROCEDURE test_plsql_table(cnt INTEGER) IS
    x TNumberList;
    BEGIN
    FOR indx IN 1 .. cnt LOOP
    x(indx) := indx;
    END LOOP;
    FOR indx in 1 .. cnt LOOP
    x.DELETE(indx);
    END LOOP;
    END;
    or
    PROCEDURE test_plsql_table(cnt INTEGER) IS
    x TNumberList;
    empty TNumberList;
    BEGIN
    FOR indx IN 1 .. cnt LOOP
    x(indx) := indx;
    END LOOP;
    x := empty;
    END;
    and so on, but result was the same.
    This is a huge problem for me as I have to manipulate collections and PL/SQL tables of very big size (from dozens of thousand of rows to millions or rows) and just a few sessions running my procedure may cause server's fall due to memory lack.
    I can not understand what Oracle reseveres such much memory for (I use local variables) -- is it a bug or a feature?
    I will be appreciated for any help.
    I use Oracle9.2.0.1.0 server under Windows2000.
    Thank you in advance.
    Dmitriy.

    Thank you, William!
    Your advice about using DBMS_SESSION.FREE_UNUSED_USER_MEMORY was very useful. Indeed it is the tool I was looking for.
    Now I write my code like this
    declare
    type TTab is table of ... index binary_integer;
    res TTab;
    empty_tab TTab;
    begin
    res(1) := ...;
    res := empty_tab;
    DBMS_SESSION.FREE_UNUSED_USER_MEMORY;
    end;
    I use construction "res := empty_tab;" to mark all memory allocated to PL/SQL table as unused according to Tom Kyte's advices. And I could live a hapy life if everything were so easy. Unfortunately, some tests I have done showed that there are some troubles in cleaning complex nested PL/SQL tables indexed by VARCHAR2 which I use in my current project.
    Let me another example.
    CREATE OR REPLACE PACKAGE rds_mdt_test IS
    TYPE TTab0 IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
    TYPE TRec1 IS RECORD(
    NAME VARCHAR2(4000),
    rows TTab0);
    TYPE TTab1 IS TABLE OF TRec1 INDEX BY BINARY_INTEGER;
    TYPE TRec2 IS RECORD(
    NAME VARCHAR2(4000),
    rows TTab1);
    TYPE TTab2 IS TABLE OF TRec2 INDEX BY BINARY_INTEGER;
    TYPE TStrTab IS TABLE OF NUMBER INDEX BY VARCHAR2(256);
    PROCEDURE test_plsql_table(cnt INTEGER);
    PROCEDURE test_str_tab(cnt INTEGER);
    x TTab2;
    empty_tab2 TTab2;
    empty_tab1 TTab1;
    empty_tab0 TTab0;
    str_tab TStrTab;
    empty_str_tab TStrTab;
    END rds_mdt_test;
    CREATE OR REPLACE PACKAGE BODY rds_mdt_test IS
    PROCEDURE test_plsql_table(cnt INTEGER) IS
    BEGIN
    FOR indx1 IN 1 .. cnt LOOP
    FOR indx2 IN 1 .. cnt LOOP
    FOR indx3 IN 1 .. cnt LOOP
    x(indx1) .rows(indx2) .rows(indx3) := indx1;
    END LOOP;
    END LOOP;
    END LOOP;
    x := empty_tab2;
    dbms_session.free_unused_user_memory;
    END;
    PROCEDURE test_str_tab(cnt INTEGER) IS
    BEGIN
    FOR indx IN 1 .. cnt LOOP
    str_tab(indx) := indx;
    END LOOP;
    str_tab := empty_str_tab;
    dbms_session.free_unused_user_memory;
    END;
    END rds_mdt_test;
    1. Running the script
    BEGIN
    rds_mdt_test.test_plsql_table ( 100 );
    END;
    I see that usage of PGA memory in my session is close to zero. So, I can judge that nested PL/SQL table indexed by BINARY_INTEGER and the memory allocated to it were cleaned successfully.
    2. Running the script
    BEGIN
    rds_mdt_test.test_str_tab ( 1000000 );
    END;
    I can see that plain PL/SQL table indexed by VARCHAR2 and memory allocated to it were cleaned also.
    3. Changing the package's type
    TYPE TTab2 IS TABLE OF TRec2 INDEX BY VARCHAR2(256);
    and running the script
    BEGIN
    rds_mdt_test.test_plsql_table ( 100 );
    END;
    I see that my session uses about 62M in PGA. If I run this script twice, the memory usage is doubled and so on.
    The same result I get if I rewrite not highest, but middle PL/SQL type:
    TYPE TTab1 IS TABLE OF TRec1 INDEX BY VARCHAR2(256);
    And only if I change the third, most nested type:
    TYPE TTab0 IS TABLE OF NUMBER INDEX BY VARCHAR2(256);
    I get the desired result -- all memory was returned to OS.
    So, as far as I can judge, in some cases Oracle does not clean complex PL/SQL tables indexed by VARCHAR2.
    Is it true or not? Perhaps there are some features in using such way indexed tables?

  • Table types?

    Hi,
       What is the use of table types?In which situation we are using the standard table ,sorted table and hashed table?Any body explain with example.
    Regards,
    Srihitha

    Hi
    There are 3 types of internal tables.
    internal tables can be classified like below.
    INDEX NON-INDEX
    STANDARD and SORTED HASHED
    Standard and sorted use indeces while hashed will not use index.
    http://www.sap-img.com/abap/what-are-different-types-of-internal-tables-and-their-usage.htm
    declaration:
    TYPES: BEGIN OF TY_STUDENT,
    SNO TYPE I,
    SNAME(5),
    END OF TY_STUDENT.
    DATA: IT_STUDENT TYPE TABLE OF TY_STUDENT (STANDARD TABLE DECL)
    DATA: IT_STUDENT TYPE SORTED TABEL OF TY_STUDENT (SORTED)
    DATA: IT_STUDENT TYPE HASHED TABLE OF TY_STUDENT WITH KEY... (HASHED)
    TYPES - tabkind
    Syntax
    ... { {STANDARD TABLE}
    | {SORTED TABLE}
    | {HASHED TABLE}
    | {ANY TABLE}
    | {INDEX TABLE} } ... .
    Effect
    Definition of the table type in an internal table.
    You can specify the non-generic table types standard table ( STANDARD TABLE), sorted table ( SORTED TABLE), and hashed table (HASHED TABLE), as well as the generic table types ANY TABLE and INDEX TABLE. The addition STANDARD is optional for standard tables.
    The non-generic table types determine the internal administration and access type in the ABAP program for an internal table:
    Standard tables are managed system-internally by a logical index. New rows are either attached to the table or added at certain positions. The table key or the index identify individual rows.
    Sorted tables are managed by a logical index (like standard tables). The entries are listed in ascending order according to table key.
    Hashed tables are managed by a hash algorithm. There is no logical index. The entries are not ordered in the memory. The position of a row is calculated by specifying a key using a hash function.
    The generic table types define a generic table type that can only be used for typing formal parameters and field symbols:
    ANY TABLE includes all table types.
    INDEX TABLE includes all standard tables and sorted tables.
    Regards
    Lalit

  • Table type row engine

    Hello,
    We are using procedures with table type:
    create type <type_name> as table (....)
    using explain plan we discover that it uses row engine.
    Is there an alternative??
    Thanks,
    Amir

    hi Srinivas,
    table type
    http://help.sap.com/saphelp_nw2004s/helpdata/en/90/8d7304b1af11d194f600a0c929b3c3/frameset.htm
    In SE11 you can create table type.
    This table type is similar to tables, but not the same way as you create tables. You can create table type with either Line type ( Nothing but a structure), Built-in ABAP types or Reference type. Assume that we have created one table type TYTAB with line type LITYP.
    So when you declare like this,
    DATA: ITAB type TYTAB - Now ITAB acts as a internal table of type TYTAB.
    DATA: LS_TYP TYPE LITYP - This LS_TYP now acts as a structure.
    So, it is clear that linetype and structure are one and the same.
    Regards,
    Santosh

  • Dynamic table type

    Hi folks,
    Is there any generic data type for table declaration, beside :
    data: lt_generic type table of data 
    I know that field-symbols can have the generic table type any
    field-symbols: <lft_generic> type any table. 
    I basically want to be able to read from generic tables.
    READ TABLE lt_generic .... 
    Thanks
    Andreas

    Hi Neil,
    actually i want to execute a read on the dynamic created tabel.
    Maybe this repot explains my purpose.
    REPORT  ztc_dqm_dynamic.
    * Step 1: << local definitions >>
    " << variables >>
    " << error string >>
    DATA: lv_error TYPE string.
    " << struc >>
    " << holds one component >>
    DATA: ls_component TYPE
          cl_abap_structdescr=>component.
    " << table >>
    DATA: lt_component TYPE cl_abap_structdescr=>component_table.
    DATA: lt_db_indexfields TYPE TABLE OF ztcc_dqm_indices.
    " << dynamic >>
    " << generated struc >>
    DATA: ls_dystruc TYPE REF TO data.
    " << generated table >>
    DATA: lt_dytable TYPE REF TO data.
    " << field symbols >>
    FIELD-SYMBOLS: <lfs_indexfields> TYPE ANY TABLE.
    FIELD-SYMBOLS: <lfs_indexfield> TYPE ANY.
    FIELD-SYMBOLS: <lfs_db_indexfields> TYPE ztcc_dqm_indices.
    " << objects >>
    DATA: lr_struc_type TYPE REF TO cl_abap_structdescr.
    DATA: lr_table_type TYPE REF TO cl_abap_tabledescr.
    " << exception >>
    DATA: lr_ex TYPE REF TO cx_sy_type_creation.
    * Step 2: << dynamic struc >>
    " << set struc fields >>
    SELECT *
      FROM ztcc_dqm_indices
        INTO TABLE lt_db_indexfields
          WHERE addr_type EQ 1
            ORDER BY index_order.
    " << get types >>
    LOOP AT lt_db_indexfields ASSIGNING <lfs_db_indexfields>.
      ls_component-name =
        <lfs_db_indexfields>-fieldname.
      ls_component-type ?=
         cl_abap_datadescr=>describe_by_name( <lfs_db_indexfields>-fieldtype ).
      APPEND ls_component TO lt_component.
    ENDLOOP.
    " << create struc >>
    TRY.
        CALL METHOD cl_abap_structdescr=>create
          EXPORTING
            p_components = lt_component
            p_strict     = abap_true
          RECEIVING
            p_result     = lr_struc_type.
      CATCH cx_sy_struct_creation INTO lr_ex.
        CALL METHOD lr_ex->if_message~get_text
          RECEIVING
            result = lv_error.
        WRITE: / lv_error.
    ENDTRY.
    " << create table >>
    TRY.
        CALL METHOD cl_abap_tabledescr=>create
          EXPORTING
            p_line_type        = lr_struc_type
    *        p_table_kind       = tablekind_std
    *        p_unique           = abap_false
    *        p_key              = p_key_kind
    *        keydefkind_default =
          RECEIVING
            p_result           = lr_table_type.
      CATCH cx_sy_table_creation INTO lr_ex.
        CALL METHOD lr_ex->if_message~get_text
          RECEIVING
            result = lv_error.
        WRITE: / lv_error.
    ENDTRY.
    " << create attributs >>
    CREATE DATA: ls_dystruc TYPE HANDLE lr_struc_type.
    CREATE DATA: lt_dytable TYPE HANDLE lr_table_type.
    * Step 3: << dynamic assignment >>
    ASSIGN lt_dytable->* TO <lfs_indexfields>.
    ASSIGN ls_dystruc->* TO <lfs_indexfield>.
    " << this works >>
    LOOP AT <lfs_indexfields> ASSIGNING <lfs_indexfield>.
    ENDLOOP.
    " << i want >>
    READ TABLE lt_dytable
      INTO ls_dystruc
        WITH KEY .....

  • Page break handeling when using table type field

    Hello everyone
    I've created an adobe form using tcode SFP.
    A table, "T1", is containing fields where one of it is a TABLE TYPE (Let give the following name "T1-FT1").
    So the structure can look like:
    T1-F1
    T1-F2
    T1-FT1-FTF1
    T1-FT1-FTF2
    basically the structure is like to have documents containing several items where those items have several serial number.
    I need to have page break per documents, per items and serial number where those one have specific header page different than the document itself.
    I need to have a page break per T1 records with specifc header.
    So for each new records of T1, I have to create a new page with it's specific header.
    The table T1-FT1 is starting on the current page, but if I have to many records to stay on the page I need to create another page with it's specific header that is different than the page 1.
    My problem is the page break handling.
    I can have the pagination tab at the Table1 and row1 level but I don't have the pagination tab at the T1-FT1 level.
    Here is what my hierarchy:
    _MasterPage
    __Page1
    __Page2
    _MainSubForm
    __Subform1
    ___Table1
    ____Row1
    _____Subform
    ______Table2
    ________Row2
    Example of Data:
    T1-F1 ___ T1-F2 __ T1-FT1-FTF1 __ T1-FT1_FTF2
    A _______ B _____  1 ___________  1
    A _______ B _____  1 ___________  2
    B _______ C _____  1 ___________  1
    B _______ D _____  1 ___________  2
    B _______ D _____  1 ___________  3
    The final page break layout should look like:
    Page1
    Header1
    A B
    ___ 1 1
    ___ 1 2
    Page2
    Header1
    B C
    ___ 1 1
    ___ 1 2
    Page 3
    Header2
    B C
    ___ 1 3
    Because there is not enough room on page 2 for the last record of the table T1-FT1, a new header is used on page 3.
    Actually several problems occurs. I cannot have the proper page break set to avoid empty pages as first or last page.
    The pagination tab stop to be available after the Row1. So we cannot set page break at the table2 and row2.
    The page break contidion doesn't work. "Well I didn't succeed to make it work".
    Any idea on how to handle those page break at table2 level?
    Is anyone had to create a PDF form where we have the date into several level of structure?
    Regards
    dstj
    Edited by: dstj on Feb 18, 2010 10:59 PM
    Edited by: dstj on Feb 18, 2010 11:00 PM

    I have the exact same issue. Could not find a solution. In my case, there are multiple subforms printed one below the other. If an expandable subform overflows into a new page, the last line overlaps with the text of next subform. I have added blank spaces between the subforms but, that does not solve the issue.
    Finally, I have managed to minimize the occurrence of the issue by doing the following. Only turn on the flag "Allow Page breaks within content" for subforms that can really spread over many pages. All other subforms, turn the flag off. This minimizes the possibility of overlapping.

  • Problem in passing select-options to class meathods , type any table

    <h1>how to pass type any table to class meathod</h1>
    <h3>hi all
           i'm trying to build class to validate the selection screen , like select-options and parameters
           while writing meathod to validate the select-options
           its throwing parameter mismath error</h3>
    <h4>i tried like made import parameter in class meathod as 'TYPE ANY TABLE' and tried to pass select-options from my program it is saying type mismatch , how to overcome this problem </h4>
    <h4>and i want to pass any select option , either of type lfa1-lifnr or mara-matnr or any other</h4>
    Moderator message : Don't shout, use proper font size for explaining the question. This has been discussed in ABAP forums before. Search for available information. Thread locked.
    Edited by: Vinod Kumar on Sep 14, 2011 11:20 AM

    hI
    Triggering and Handling events
    At the moment of implementation, a class defines its:
             Instance events (using the EVENTS statement)
            Static events (using the CLASS-EVENTS statement)
    Classes or their instances that receive a message when an event is triggered at runtime and want to react to this event define event handler methods. Statement: METHODS
    CLASS IC1_VEICHLE DEFINATION.
    PUBLIC SECTION.
    METHOD CONSTRUCTOR IMPORTING
    EVENTS VEICHEL_CREATION.
    ENDCLASS
    CLASS LC1_VEICHLE IMPLIMENTATION.
    METHOD CONSTRUCTOR
    RAISE EVENT VEICHLE_CREATION.
    REWARD IF USEFULL

  • Managing statistics for object collections used as table types in SQL

    Hi All,
    Is there a way to manage statistics for collections used as table types in SQL.
    Below is my test case
    Oracle Version :
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    SQL> Original Query :
    SELECT
         9999,
         tbl_typ.FILE_ID,
         tf.FILE_NM ,
         tf.MIME_TYPE ,
         dbms_lob.getlength(tfd.FILE_DATA)
    FROM
         TG_FILE tf,
         TG_FILE_DATA tfd,
              SELECT
              FROM
                   TABLE
                        SELECT
                             CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
                             OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
                        FROM
                             dual
         )     tbl_typ
    WHERE
         tf.FILE_ID     = tfd.FILE_ID
    AND tf.FILE_ID  = tbl_typ.FILE_ID
    AND tfd.FILE_ID = tbl_typ.FILE_ID;
    Elapsed: 00:00:02.90
    Execution Plan
    Plan hash value: 3970072279
    | Id  | Operation                                | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                         |              |     1 |   194 |  4567   (2)| 00:00:55 |
    |*  1 |  HASH JOIN                               |              |     1 |   194 |  4567   (2)| 00:00:55 |
    |*  2 |   HASH JOIN                              |              |  8168 |   287K|   695   (3)| 00:00:09 |
    |   3 |    VIEW                                  |              |  8168 |   103K|    29   (0)| 00:00:01 |
    |   4 |     COLLECTION ITERATOR CONSTRUCTOR FETCH|              |  8168 | 16336 |    29   (0)| 00:00:01 |
    |   5 |      FAST DUAL                           |              |     1 |       |     2   (0)| 00:00:01 |
    |   6 |    TABLE ACCESS FULL                     | TG_FILE      |   565K|    12M|   659   (2)| 00:00:08 |
    |   7 |   TABLE ACCESS FULL                      | TG_FILE_DATA |   852K|   128M|  3863   (1)| 00:00:47 |
    Predicate Information (identified by operation id):
       1 - access("TF"."FILE_ID"="TFD"."FILE_ID" AND "TFD"."FILE_ID"="TBL_TYP"."FILE_ID")
       2 - access("TF"."FILE_ID"="TBL_TYP"."FILE_ID")
    Statistics
              7  recursive calls
              0  db block gets
          16783  consistent gets
          16779  physical reads
              0  redo size
            916  bytes sent via SQL*Net to client
            524  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              2  rows processed Indexes are present in both the tables ( TG_FILE, TG_FILE_DATA ) on column FILE_ID.
    select
         index_name,blevel,leaf_blocks,DISTINCT_KEYS,clustering_factor,num_rows,sample_size
    from
         all_indexes
    where table_name in ('TG_FILE','TG_FILE_DATA');
    INDEX_NAME                     BLEVEL LEAF_BLOCKS DISTINCT_KEYS CLUSTERING_FACTOR     NUM_ROWS SAMPLE_SIZE
    TG_FILE_PK                          2        2160        552842             21401       552842      285428
    TG_FILE_DATA_PK                     2        3544        852297             61437       852297      852297 Ideally the view should have used NESTED LOOP, to use the indexes since the no. of rows coming from object collection is only 2.
    But it is taking default as 8168, leading to HASH join between the tables..leading to FULL TABLE access.
    So my question is, is there any way by which I can change the statistics while using collections in SQL ?
    I can use hints to use indexes but planning to avoid it as of now. Currently the time shown in explain plan is not accurate
    Modified query with hints :
    SELECT    
        /*+ index(tf TG_FILE_PK ) index(tfd TG_FILE_DATA_PK) */
        9999,
        tbl_typ.FILE_ID,
        tf.FILE_NM ,
        tf.MIME_TYPE ,
        dbms_lob.getlength(tfd.FILE_DATA)
    FROM
        TG_FILE tf,
        TG_FILE_DATA tfd,
            SELECT
            FROM
                TABLE
                        SELECT
                             CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
                             OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
                        FROM
                             dual
        tbl_typ
    WHERE
        tf.FILE_ID     = tfd.FILE_ID
    AND tf.FILE_ID  = tbl_typ.FILE_ID
    AND tfd.FILE_ID = tbl_typ.FILE_ID;
    Elapsed: 00:00:00.01
    Execution Plan
    Plan hash value: 1670128954
    | Id  | Operation                                 | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                          |                 |     1 |   194 | 29978   (1)| 00:06:00 |
    |   1 |  NESTED LOOPS                             |                 |       |       |            |          |
    |   2 |   NESTED LOOPS                            |                 |     1 |   194 | 29978   (1)| 00:06:00 |
    |   3 |    NESTED LOOPS                           |                 |  8168 |  1363K| 16379   (1)| 00:03:17 |
    |   4 |     VIEW                                  |                 |  8168 |   103K|    29   (0)| 00:00:01 |
    |   5 |      COLLECTION ITERATOR CONSTRUCTOR FETCH|                 |  8168 | 16336 |    29   (0)| 00:00:01 |
    |   6 |       FAST DUAL                           |                 |     1 |       |     2   (0)| 00:00:01 |
    |   7 |     TABLE ACCESS BY INDEX ROWID           | TG_FILE_DATA    |     1 |   158 |     2   (0)| 00:00:01 |
    |*  8 |      INDEX UNIQUE SCAN                    | TG_FILE_DATA_PK |     1 |       |     1   (0)| 00:00:01 |
    |*  9 |    INDEX UNIQUE SCAN                      | TG_FILE_PK      |     1 |       |     1   (0)| 00:00:01 |
    |  10 |   TABLE ACCESS BY INDEX ROWID             | TG_FILE         |     1 |    23 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       8 - access("TFD"."FILE_ID"="TBL_TYP"."FILE_ID")
       9 - access("TF"."FILE_ID"="TBL_TYP"."FILE_ID")
           filter("TF"."FILE_ID"="TFD"."FILE_ID")
    Statistics
              0  recursive calls
              0  db block gets
             16  consistent gets
              8  physical reads
              0  redo size
            916  bytes sent via SQL*Net to client
            524  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              2  rows processed
    Thanks,
    B

    Thanks Tubby,
    While searching I had found out that we can use CARDINALITY hint to set statistics for TABLE funtion.
    But I preferred not to say, as it is currently undocumented hint. I now think I should have mentioned it while posting for the first time
    http://www.oracle-developer.net/display.php?id=427
    If we go across the document, it has mentioned in total 3 hints to set statistics :
    1) CARDINALITY (Undocumented)
    2) OPT_ESTIMATE ( Undocumented )
    3) DYNAMIC_SAMPLING ( Documented )
    4) Extensible Optimiser
    Tried it out with different hints and it is working as expected.
    i.e. cardinality and opt_estimate are taking the default set value
    But using dynamic_sampling hint provides the most correct estimate of the rows ( which is 2 in this particular case )
    With CARDINALITY hint
    SELECT
        /*+ cardinality( e, 5) */*
    FROM
         TABLE
              SELECT
                   CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
                   OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
              FROM
                   dual
         ) e ;
    Elapsed: 00:00:00.00
    Execution Plan
    Plan hash value: 1467416936
    | Id  | Operation                             | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                      |      |     5 |    10 |    29   (0)| 00:00:01 |
    |   1 |  COLLECTION ITERATOR CONSTRUCTOR FETCH|      |     5 |    10 |    29   (0)| 00:00:01 |
    |   2 |   FAST DUAL                           |      |     1 |       |     2   (0)| 00:00:01 |
    With OPT_ESTIMATE hint
    SELECT
         /*+ opt_estimate(table, e, scale_rows=0.0006) */*
    FROM
         TABLE
              SELECT
                   CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
                   OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
              FROM
                   dual
         ) e ;
    Execution Plan
    Plan hash value: 4043204977
    | Id  | Operation                              | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                       |      |     5 |   485 |    29   (0)| 00:00:01 |
    |   1 |  VIEW                                  |      |     5 |   485 |    29   (0)| 00:00:01 |
    |   2 |   COLLECTION ITERATOR CONSTRUCTOR FETCH|      |     5 |    10 |    29   (0)| 00:00:01 |
    |   3 |    FAST DUAL                           |      |     1 |       |     2   (0)| 00:00:01 |
    With DYNAMIC_SAMPLING hint
    SELECT
        /*+ dynamic_sampling( e, 5) */*
    FROM
         TABLE
              SELECT
                   CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
                   OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
              FROM
                   dual
         ) e ;
    Elapsed: 00:00:00.00
    Execution Plan
    Plan hash value: 1467416936
    | Id  | Operation                             | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                      |      |     2 |     4 |    11   (0)| 00:00:01 |
    |   1 |  COLLECTION ITERATOR CONSTRUCTOR FETCH|      |     2 |     4 |    11   (0)| 00:00:01 |
    |   2 |   FAST DUAL                           |      |     1 |       |     2   (0)| 00:00:01 |
    Note
       - dynamic sampling used for this statement (level=2)I will be testing the last option "Extensible Optimizer" and put my findings here .
    I hope oracle in future releases, improve the statistics gathering for collections which can be used in DML and not just use the default block size.
    By the way, are you aware why it uses the default block size ? Is it because it is the smallest granular unit which oracle provides ?
    Regards,
    B

Maybe you are looking for

  • Need help on ODI error table

    Hi all, I need to know following things 1) I have created open few tools and if business validation fails it throws OpenToolExecutionException with some error code now I want to check in which SNP_ table it goes and how cud I track my error info. 2)

  • Cannot force Safari to use Adobe Reader in Leopard for pdf

    Vanguard.com only supports download of pdfs on a Mac if Safari is using Adobe Reader. (Yes, that's totally awesome.) I can't seem to force Safari to do that; it will only use Safari's built-in pdf reader. - In Adobe Reader 8.1.1's preferences, the op

  • Invoice block for delayed delivery of goods

    Hi, Is it possible to block invoices with delayed goods delivery  than planned delivery date? in  SRM 5.0 ( SP07). I was looking for it and there is tolerance key PZ (time over run) which is applicable for CONF only. How could be achieved this requir

  • Dreamweaver will not open. Have a project due Friday and have to finish. :(

    When i was working late lastnight, I noticed that when I tried to insert a spry menu into a new page I created, that Dreamweaver kept shutting down on me. I would restart, try again and the same would happen. So I just shut down thinking I'm just tir

  • Unable to open photo's e-mailed to me in .jpg format

    When I receive a photo I am unable to open it. A blank page on Live Photo Gallery flashes but no photo appears. All photo's are jpg I have sent the same e-mail to my work PC and photo opens just fine. Thank You