Sort items in Table type
Hi All,
I have an object type defined as:
create or replace type test_object as object
item varchar2(50)
, countofitems number(8,0)
And I have a table type defined on this object as:
create or replace table test_object_table is table of test_object;
I am populating the object into them as:
test_object.item := <somename from table>;
test_object.countofitems := <count value>;
test_object_table.EXTEND(1);
test_object_table(test_object_table) := test_object;
The above logic is performed inside a loop statement which has a select query in it. The loop's select query gets the count of each item - one per loop.
Is there anyway, after my loop ends and table type is populated, to sort the data inside in DESC order of countofitems?
Thanks,
Chaitanya
Hi,
yes my data comes from a cursor but that cursor selects counts for one item type at a time only---->
meaning, my cursor is inside another loop statement which provides one value at a time to be used in the WHERE clause.
so essentially, for every loop i would get the counts for 1 item type. each time i am inserting the data into my table type.
if my cursor fetched counts for all items at once, then i could have sorted it , but that is not the case here.
Is there any way I can sort the data once the table type is populated??
Similar Messages
-
Sort/filter datablock based on procedure that return table type
Hi All,
I’ve got datablock based on procedure that return table type. In the form I have to provide ‘filter and sort records’ functionality. Previously, using tables/views based datablocks, I’ve done that by using:
-- filter
SET_BLOCK_PROPERTY (L_BLOCK_NAME, DEFAULT_WHERE, L_WHERE_CLAUSE);
-- sort
SET_BLOCK_PROPERTY(L_BLOCK_NAME ,ORDER_BY, L_ORDER_BY_CLAUSE);
-- and then
EXECUTE_QUERY;
It doesn’t work with procedure that return table type. How I can do that?
BartekI agree with Andreas, from the sample you have given us, I don't see any reason why you could not merge these queries into a single UNION/UNION ALL query. Also, I would add your summation query to your main query to eliminate this extra step. The result would look something like:
SELECT DISTINCT
pih.id
,d.document_id
,pih.doc_serial_no
,pih.purch_invoice_date
,oh.company_name
,(SELECT NVL(SUM(amount),0)
FROM "YOUR TABLE HERE" yth
WHERE yth."YOUR COLUMN HERE" = pih.id) AS sum_amount
FROM "YOUR TABLES HERE"
WHERE "YOUR JOIN CONDITIONS HERE"
UNION ALL
SELECT DISTINCT
sih.id
,d.document_ind
,sih.doc_serial_no
,sih.sales_invoice_date
,sih.company_name
,(SELECT NVL(SUM(amount),0)
FROM "YOUR TABLE HERE" yth
WHERE yth."YOUR COLUMN HERE" = sih.id) AS sum_amount
FROM "YOUR TABLES HERE"
WHERE "YOUR JOIN CONDITIONS HERE"
[/code]
Hope this helps.
Craig...
+If a response is helpful or correct, please mark it accordingly+
Edited by: CraigB on Feb 23, 2010 1:39 PM
It appears the CODE tags are not working as well as the URL tags. :( -
Table type with reference type - how to sort?
I have an internal table lt_refs of the type ZXX_TT_REFS.
The table type ZXX_TT_REFS is a table of references ("ref. type") to the class ZCL_C.
The class C has an attribute attr1.
Now I would like to sort that table. Is there an easy (built-in) way to do this?
DATA lt_refs TYPE ZXX_TT_REFS.
DATA lr_ref TYPE REF TO ZCL_C.
LOOP AT lt_refs INTO lr_ref.
"Sort based on lr_ref->attr1. ?
ENDLOOP.
"or can I
SORT lt_refs BY attr1.
"directly?Danial, please see the following. In the case where you want to sort your reference by an attribute within the object, you can do something like this.
report zrich_0001.
* CLASS lcl_tab DEFINITION
class lcl_app definition.
public section.
data: attri type i.
methods: constructor importing im_attri type i.
endclass.
* CLASS lcl_tab IMPLEMENTATION
class lcl_app implementation.
method constructor.
attri = im_attri.
endmethod.
endclass.
data: a_app type ref to lcl_app.
data: a_app_list type table of ref to lcl_app.
start-of-selection.
create object a_app exporting im_attri = 3 .
append a_app to a_app_list.
create object a_app exporting im_attri = 2 .
append a_app to a_app_list.
create object a_app exporting im_attri = 1 .
append a_app to a_app_list.
sort a_app_list by <b>table_line->attri</b> ascending .
check sy-subrc = 0.
Here is the documentation.
<i>
<b>
Access to Attributes with References in Internal Tables</b>
If the line type of internal tables includes reference variables as components comp, the attributes attr of the object to which the reference in a line points can be used as key values for reading, sorting and changing table rows. This is possible in the following statements:
,,LOOP AT itab ... WHERE comp->attr ...
,,READ TABLE itab ... WITH [TABLE] KEY comp->attr = ...
<b>,,SORT itab BY comp->attr ...</b>
,,DELETE itab WHERE comp->attr ...
,,MODIFY itab ... TRANSPORTING ... WHERE comp->attr ...
<b>If a table contains unstructured lines with the type of a reference variable, the attributes of the object to which a line points can be addressed using TABLE_LINE->attr.</b>
</i>
Regards,
RIch Heilman -
Internal Table Types (Standard, Sorted, Hashed)
Hi all,
I wonder about using internal table types. I always work with standard table type. I don't know when i have to use the standard, sorted or hashed itab type. Is there limits for line counts of types, like over 200.000 lines use hashed table type etc. ? I need performance improvements for itabs.
Thx,the terminology of internal tables is unfortunately quite confusing:
internal tables use 'index' for the row number of the line in the table, if you know then you can access it directly. It is actually the sy-tabix variable which you have to know.
Things which are called index on the database are called keys, i.e. the sorted primary key of a SORTED table or the hashed primary key of a HASHED table (the technical realization is actually called index).
With the newest basis release (7.02 or 7.20) there are also secondary keys possible on internal tables, for all 3 types.
Siegfried -
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 -
Passing parameters to PL/SQL table types
Hi Everybody,
I have one question about passing PL/SQL tables types and tabs as IN parameter in procedure.I am working in 11.2.0.2.0 environment. I am stuck on how to pass those values to procedure.Please find below more details:
Table 1:
CREATE TABLE ITEMS
ITEM_ID VARCHAR2(40 BYTE) NOT NULL,
ITEM_NAME VARCHAR2(40 BYTE),
SERIAL NUMBER(2),
ADDED_ON DATE);
Table 2:
CREATE TABLE ITEM_ACTIVITY_INFO
ITEM_ID VARCHAR2(40 BYTE) NOT NULL,
ACCOUNT_TYPE VARCHAR2(1 BYTE),
ID_NUMBER NUMBER(3),
ACTIVATION_DATE DATE);
Table 3:
CREATE TABLE ITEM_GROUP
GROUP_ID NUMBER(2) NOT NULL,
ITEM_ID VARCHAR2(40 BYTE),
GROUP_TYPE VARCHAR2(20 BYTE),
GROUP_DATE DATE);
Table 4:
CREATE TABLE ITEM_ADDRESS
GROUP_ID NUMBER(2) NOT NULL,
NAME VARCHAR2(60 BYTE),
ADDRESS VARCHAR2(100));
Following types are created:
CREATE OR REPLACE TYPE ITEMS_TYPE AS OBJECT
ITEM_ID VARCHAR2(40 BYTE),
ITEM_NAME VARCHAR2(40 BYTE),
SERIAL NUMBER(2),
ADDED_ON DATE);
CREATE OR REPLACE TYPE ITEM_ACTIVITY_TYPE AS OBJECT
ITEM_ID VARCHAR2(40 BYTE),
ACCOUNT_TYPE VARCHAR2(1 BYTE),
ID_NUMBER NUMBER(3),
ACTIVATION_DATE DATE);
CREATE OR REPLACE TYPE ITEM_GROUP_COMP_TYPE AS OBJECT
GROUP_ID NUMBER(2) NOT NULL,
ITEM_ID VARCHAR2(40 BYTE),
GROUP_TYPE VARCHAR2(20 BYTE),
GROUP_DATE DATE
ITEM_ADDRESS_IN ITEM_ADDRESS_TYPE);
CREATE OR REPLACE TYPE ITEM_ADDRESS_TYPE AS OBJECT
GROUP_ID NUMBER(2),
NAME VARCHAR2(60 BYTE),
ADDRESS VARCHAR2(100));
CREATE OR REPLACE TYPE ITEM_GROUP_COMP_TAB AS TABLE OF ITEM_GROUP_COMP_TYPE;
Create or replace procedure ITEM_ADD_CHANGE(
ITEM_IN IN ITEMS_TYPE,
ITEM_ACTIVITY_IN IN ITEM_ACTIVITY_TYPE,
ITEM_GROUP_IN IN ITEM_GROUP_COMP_TAB,
ITEM_OUT IN OUT ITEMS.ITEM_ID%TYPE);
Above are the paramteres we are passing to procedure.
I need help in how to pass parameters to above procedure. All comments and responses will be highly appreciated. Thanks everyone for going through the post. Please let me know if more more information is required on this problem.
Regards
DevBilly Verreynne wrote:
Types used in this fashion, only make sense if the table is based on the type. It makes very little sense to have a table structure and then to duplicate the structure using a type.
The 2 structures may be defined the same. But they are NOT interchangeable and requires one to be converted to the other to use. This is not sensible in my view. It is far easier in that case to simply use the PL/SQL macro +%RowType+ to create a duplicate structure definition - one that can natively be used for touching that table, without conversions required.
If you do want to use types, define the type, then define the table of that type, adding the required constraints (pk, fk, not null, check) to the table's definition.Billy:
Just curious, why do you say it makes very little sense to have a type modeled on a table? I do that a lot. In my case, I am getting the values from an external program, not building them manually, but it makes a lot of sense to me.
One application where I do this a lot has a java front-end that parses HL7 messages. Each message contains at least minimal information about a variable number of entities (and often several rows for an entity) in the database, and must be processed as a single atomic trasnaction. So, rather than have potentially hundreds of parameters to the "main" driver procedures for different message types I created a set of types more or less identical to the tables representing the entities. The java program parses the mesasge and populates the type, then calls the appropriate stored procedure for the message type passing in the populated types. My stored procedure then does inserts/updates or deletes as appropriate over potentially dozens of tables.
John -
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 PMI 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. -
Sort the internal table based on the vendor field
hello experts,
I am stuck with a small problem...
I am uploading the data for partner association for vendors through lsmw BI program.
I am collecting all the records in the end of trasaction and downloading all those records on to the apps server.
I declared one internal table as
TYPES: BEGIN OF type_erecord,
mesg(1000) TYPE c,
END OF type_erecord.
DATA: t_precord type standard table of type_erecord initial size 0,
w_precord type type_erecord.
I am concatenating all the fields and moving to the internal table..
concatenate zvendor_master-source zvendor_master-lifnr blf00-lifnr
zvendor_master-lname zvendor_master-parvw
zvendor_master-psource zvendor_master-pname
zvendor_master-lifn2 bwyt3-lifn2
zvendor_master-ekorg zvendor_master-werks
w_PLANT-muplant zvendor_master-defpa
v_message
into w_precord-mesg separated by c_pipe.
append w_precord to t_precord.
now at the end I have to sort this internal table t_precord based on blf00-lifnr
can any one guide me how to do it
Thanks for your anticipation
NiteshaOK...
Than you can create one more table and do the process of sorting and than put data into the final table.
TYPES: BEGIN OF type_erecord,
mesg(1000) TYPE c,
END OF type_erecord.
DATA: t_precord type standard table of type_erecord initial size 0,
w_precord type type_erecord.
TYPES: BEGIN OF type_erecord_1,
mesg(1000) TYPE c,
lifnr type blf00-lifnr , "<<<
END OF type_erecord_1.
DATA: t_precord_1 type standard table of type_erecord initial size 0,
w_precord_1 type type_erecord.
I am concatenating all the fields and moving to the internal table..
concatenate zvendor_master-source zvendor_master-lifnr blf00-lifnr
zvendor_master-lname zvendor_master-parvw
zvendor_master-psource zvendor_master-pname
zvendor_master-lifn2 bwyt3-lifn2
zvendor_master-ekorg zvendor_master-werks
w_PLANT-muplant zvendor_master-defpa
v_message
into w_precord_1-mesg separated by c_pipe.
w_precord_1-lifnr = blf00-lifnr . " <<<
append w_precord_1 to t_precord_1. " <<<
SORT T_PRECORD_1 by LIFNR. " <<
LOOP AT T_PRECORD_1 into w_precord_1.
move-corresponing w_precord_1 to w_precord.
append w_precord to T_PRECORD.
clear w_precord .
endloop.
Regards,
Naimesh Patel -
Anybody please resolve my doubt
types tb_std_type type table of sflight.
-->this i understand as not a generic table type.'NON-UNIQUE" and DEFAULT KEYS are implicity defined .
data it_std type tb_std.-->Since i could declare an internal table of tb_std_type,i strongly belive tb_std_type is not a genric table type.
But when i try to declare another type of same table type tb_std_type ie
types tb2_type type tb_std_type.
This is giving me an error saying\
tb_std_type has a generic type.Use of this type is only possible for typing field symbols and formal parameters.
If thats true then how was i able to create a internal table out of it...
In case of sorted and hashed tables it behaves as exactly as it is defined.(Like if generic,can only be used for typing formal params.field symbold..and if non generic--internal tables declaration and normal typing is possible)
Please resolve this
*Would be great if could avoid a copy paste from std.help..because i have been through it..Hello Teenu,
Query#1
types tb2_type type tb_std_type.
This is giving me an error saying\
tb_std_type has a generic type.Use of this type is only possible for typing field symbols and formal parameters.
Why is the table generic? An excerpt from SAP documentation clearly states that:
An internal table that has no table key or an incomplete table key is generic with respect to the table key. A table type of this nature can be used only for typing formal parameters or field symbols.
Query#2
If thats true then how was i able to create a internal table out of it...
SAP says:
A standard table type with a generic primary table key can only be specified after TYPE when DATA is used.
Source: [http://help.sap.com/abapdocu_70/en/ABAPTYPES_KEYDEF.htm|http://help.sap.com/abapdocu_70/en/ABAPTYPES_KEYDEF.htm]
BR,
Suhas -
How to sort an internal table with a header line?
hi all,
i have declared table i_bseg type standard table of bseg with header line.
now i have populated data in i_bseg.
now i am sorting it by bukrs
ie i am writing sort i_bseg by bukrs.
before sorting all i_bseg-belnrs were populated...
but after sorting the contents of the i_bseg is changing.
some of the belnrs are getting deleted..
is there any special way to sort an internal table with header line...?hi,
<b>SORT <itab> [ASCENDING|DESCENDING] [AS TEXT] [STABLE].</b>
The statement sorts the internal table <itab> in ascending order by its key.<b> The statement always applies to the table itself, not to the header line</b>.
If you have an internal table with a structured line type that you want sort by a different key, you can specify the key in the SORT statement:
SORT <itab> [ASCENDING|DESCENDING] [AS TEXT] [STABLE]
BY <f1> [ASCENDING|DESCENDING] [AS TEXT]
<fn> [ASCENDING|DESCENDING] [AS TEXT].
<b>this is your sort statement: sort i_bseg by bukrs.
you try with this statement: sort i_bseg by bukrs STABLE.</b>
regards,
Ashokreddy -
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,
BThanks 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 -
BI - Purchase document's item level contion type and correspondingvalue.
Dear Experts
I would like to know - Is there any standard data source in BI for item level condition type and values of Purchase order document. These are available in SAP R/3 . Shall be grateful, if you could kindly help me out
Kind regards - P.L.DeyHi,
Actually, These informations are stored in Characteristics and Key Figures i.e., CVCs(characteristic value combinations)
When you do Purchase Order,
These Values will store in PURCHIS ( Purchasing Information Systems) and that to, in Open Information Warehouse Data base in the form of CVCs. (In Particular Table forms)
EG.,
Values are stored in Key Figures (Eg., Number....)
Names are stored in Characteristics ( Eg., Purchase order..)
in CVC, we can easily see, Number of purchase orders for vendor, or so.....
Hopes it is useful
Thanks. -
Whats is table type ? whats the use of it in abap?
hi,
i am ahmed abap fresher,
i want to know what is table type and whats the use of it. at what point/situation we utilize this table type.Hi Ahmed ,
Table is apart of data dictionary.
Table is a sort of container where we store data.
For eg. you want to store customer record in the database.Now you will store that customer record against specific fields of the applicable table.
You can create or see table by means of transaction code se11.
There are 3 typesof tables available in SAP ABAP:
1. Transparent table
2. Pool table
3. Cluster table.
Transparent Table:
A physical table definition in the database for the table definition which is stored in the ABAP Dictionary for transparent tables when the
table is activated. The table definition is translated from the ABAP
Dictionary to a definition of the particular database.
Pooled table:
Pooled tables can be used to store control data (e.g. screen sequences,
program parameters or temporary data). Several pooled tables can be
combined to form a table pool. The table pool corresponds to a physical
table on the database in which all the records of the allocated pooled
tables are stored.
Cluster table:
Cluster tables contain continuous text, for example, documentation.
Several cluster tables can be combined to form a table cluster. Several
logical lines of different tables are combined to form a physical record
in this table type. This permits object-by-object storage or
object-by-object access. In order to combine tables in clusters, at
least parts of the keys must agree. Several cluster tables are stored in
one corresponding table on the database.
See the documetation at:
http://help.sap.com/saphelp_nw04/helpdata/en/cf/21f083446011d189700000e8322d00/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/81/415d363640933fe10000009b38f839/frameset.htm
Reward if useful ...
Regards ,
Shankar GJ -
Question on using table types in methods
Hi
I have a simple question involving passing table types in method
I want to pass an internal table by reference - to a method and within the method populate the internal table (t1) using a select * into the internal table and then sort t1 by f1 and f2. t1 is an internal table based on a ABAP dictionary table ( at1 )
Question is : If I use a generic type TABLE declaration , it does not allow sort operation specifically by fields. If I use type at1 as in
the METHODS M1 exporting t1 type at1statement, syntax error is - t1 is not an internal table.
How do I achieve the above using the method implementation ?
Sample code that I try
CLASS C1 DEFINITION
PUBLIC SECTION
METHODS M1 exporting t1 type table
ENDMETHOD
ENDCLASS
CLASS C1 IMPLEMENTATION
METHOD M1
select * from at1 into t1.
sort t1 field f1 f2
ENDCLASSYou should define a TABLE TYPE based upon the data dictionary type (at1) either in the data dictionary using SE11 or in the TYPES section of the class.
Then define the parameter of this new type.
Cheers
Graham Robbo -
Hi friends.
I am currentyl trying to find a way to sort a table which only has dynamic attributes. I do not know the structure type at design and runtime.
So how can I get a table of the dynamic attributes of a node like get_static_attributes_table( )?
Any ideas are welcome.
Cheers,
SaschaHi Sascha,
Did you try using
data : Table type table
Maybe you are looking for
-
How to change apple id on iPhone? Wife and I have same apple ID which causes me to get her iMessages instead of her. I also get all her pics on my phone and I don't want them. We need to change her apple ID without causing my ID and cloud to be clos
-
How do I change a character in the document to another character in one command?
How do I change a character in the document to another character in one command?
-
Responsive Scaling Makes Texts on The Buttons Disappear
Hi, I made an animation which has buttons, their hover animation states, and text on each button. When I activate responsive scaling function and preview the result, texts on the buttons (which are located right half of the screen somehow) disappear!
-
Running two programs on one screen
Hi, is there a possibility to run two different programs on one screen, independantly from each other. Or is this a kind of Container in which you can run a program?
-
EIS drill through report build
Hi,<BR><BR>I want to create multiple drill through reports using EIS. But looks like I need to create all the required reports before I build and load the cube. Once I have built the cube using EIS, I cannot go in the metaoutline and add new drill th