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
ENDCLASS
You 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
Similar Messages
-
Hi All,
I am trying to create one RFC. But in that RFC, I wish to use Table types as import and export parameters completly avoiding Tables tab. Will that effect the performance of RFC if I use Table types. If Yes, Please give clear clarification where it effects the performance.
Also please let me know how the performance of the RFC is effected if we use Tables tab.
Thanks,
Ravee.."I wish to use Table types as import and export parameters completly avoiding Tables tab."
I'm not sure if Tables can be avoided, if just using regular ABAP. I know that the Importing tab would not work when I tried it (under vrs 4.6b).
Because you are launching separate processes, in separate memory areas: any parameter you use in RFC has to be known by the calling and the callee functions/programs. This means that you need a common reference. If you have more than one function module in a function group, you can use the TOP file and a 'Z' data dictionary structure.
I hope that this helps,
Dan Perecky -
How to use table type in bulk collect
Hi experts,
How to use table type in bulk collect see the procedure used( oracle 10g)
and error is
PLS-00597: expression 'REQ_REC' in the INTO list is of wrong type
CREATE OR REPLACE PROCEDURE SAMPLE_SP IS
TYPE TYP_A AS OBJECT
( COLMN1 TABLE1.COLM1%TYPE,
COLMN2 TABLE1.COLM2%TYPE,
COLMN3 TABLE1.COLM3%TYPE
TYPE REC_A IS TABLE OF TYP_A;
REQ_REC A_REC;
CURSOR REQ_CUR IS SELECT COLM1,COLM2,COLM3 FROM TABLE1 WHERE <CONDITION>;
BEGIN
OPEN REQ_REC;
LOOP
EXIT WHEN REQ_REC%NOTFOUND;
FETCH REQ_REC BULK COLLECT INTO REQ_REC LIMIT 1000;
FOR I IN 1..REQ_REC.COUNT
LOOP
<insert statement>
END LOOP;
COMMIT;
END LOOP;
END SAMPLE_SP;
Many thanks,
Kalingaok but that is not an issue..
Hi experts,
How to use table type in bulk collect see the procedure used( oracle 10g)
and error is
PLS-00597: expression 'REQ_REC' in the INTO list is of wrong type
CREATE OR REPLACE PROCEDURE SAMPLE_SP IS
TYPE TYP_A AS OBJECT
( COLMN1 TABLE1.COLM1%TYPE,
COLMN2 TABLE1.COLM2%TYPE,
COLMN3 TABLE1.COLM3%TYPE
TYPE REC_A IS TABLE OF TYP_A;
REQ_REC A_REC;
CURSOR REQ_CUR IS SELECT COLM1,COLM2,COLM3 FROM TABLE1 WHERE <CONDITION>;
BEGIN
OPEN REQ_CUR;
LOOP
EXIT WHEN REQ_REC%NOTFOUND;
FETCH REQ_REC BULK COLLECT INTO REQ_REC LIMIT 1000;
FOR I IN 1..REQ_REC.COUNT
LOOP
<insert statement>
END LOOP;
COMMIT;
END LOOP;
END SAMPLE_SP;
Many thanks,
Kalinga
Message was edited by:
Kalinga -
Datasources with function module which uses table type
hi..
I am creating a datasource which extracts data using a function module from xRPM to BW. When creating the function module it gives an error " TABLES parameters are obsolete!" while trying to specify the extract structure. I searched in SDN and learnt that we need to use table types and use that in the changing tab.Not sure how that works and where we need to use the extract structure for this.
Could someone please explain this to me and let me know how i can create my datasource using this type of function module.Hi,
in your case you need the tables parameter, as the service api expects the result of the fm in a table called e_t_data. Of course table parameters are obsolet but you can just ignore the warning and it will work.
regards
Siggi
PS: Extraction fm must follow a strict interface definition.
Message was edited by:
Siegfried Szameitat -
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. -
Using TABLE type,display '???'
Recently,I want pass a TABLE as parameter from PLSQL to java.
the TABLE is consisted of Object;
Following is source code:
step1:
CREATE OR REPLACE TYPE o_obj AS OBJECT
id number,
name varchar2(50),
CONSTRUCTOR FUNCTION obj008 RETURN SELF AS RESULT
step 2:
CREATE OR REPLACE TYPE nt_rec_objs IS TABLE OF o_obj
step 3:
create or replace package PKG_PUB_SCD_BATCH is
procedure p_test(
o_param1 in number,
o_rs out nt_rec_objs
)as
begin
end;
step4:
In java,call the procedure by oracle.jdbc.*
If the value is number,Java will print it .
If the value is other predefined type(varchar,varchar2,char etc) .Java will print '???'.
First I think it caused by different character set.
when I change procedure P_TEST,make it pass directly a varchar2,not a TABLE,
Java can print it normally.
I do know why it is .Who can help me??Hi,
I am using table emp having fields id,name,,,,,,,,,photo,mimetype,filename,last_update_date.
photo is of type BLOB. I updated photo (text item) on form.
I Used BLOB DOWNLOAD Format Mask with appropriate entries & selected display as Attachment.
So my problem is partially solved. Now if DOWNLOAD link on Form is clicked it displays Excel sheet
in different window. But still, DOWNLOAD link on my Interactive report not working properly.
DOWLOAD on interactive if it is clicked it has two problems
1) It opens image or notepad file in same window.
2) Not able to open Excel sheet.
thanks for reply. -
In Smartforms can i use table type which has table inside table
Hi ,
I would like to know whether in Form Interface can we declare table type which has a table and one of its field is again a table( Nested tables)..
Can we declare like that ?? Need your suggestions please...
Rgds.,
subashYes, we can.
Check Smartform LB_BIL_INVOICE
Importing parameter IS_BIL_INVOICE TYPE LBBIL_INVOICE
Regards,
Naimesh Patel -
Question of using table?
Hi
I have a problem for measurement and it will get some numeric data to LabVIEW. I want to put all the data into a table and the format is as below.
No. Total Time
1 4 11
12
10
11
2 3 23
14
18
3 3 12
11
15
No. is the total number of loop has been executed. Total is the number of time I get. Time is an array generated in each loop. I don't know how to program for this format. Any suggestion?
Bill.Hello,
look attached vi.
It simulates measurement data in your format and print to table.
Good luck.
Attachments:
table_sim.zip 17 KB -
Hi All,
can anyone tell me
What does table type mean?
Why table type is used?
What are the advantages of using Table Type?
Regards,
Chandra PrakashHi,
Table Types
A table type describes the structure and functional attributes of an internal table in ABAP. In ABAP programs you can reference a table type TTYP defined in the ABAP Dictionary with the command DATA <inttab> TYPE TTYP. An internal table <inttab> is created in the program with the attributes defined for TTYP in the ABAP Dictionary.
A table type is defined by:
its line type, that defines the structure and data type attributes of a line of the internal table
the options for managing and accessing the data ( access mode) in the internal table
the key ( key definition and key category) of the internal table
The row type is defined by directly entering the data type, length and number of decimal places or by referencing a data element, structured type ( structure, table or view) or other table type. Or the row type can be a reference type.
Table type TABTYPE shown in the graphic can be used with the statement DATA <name> TYPE TABTYPE in ABAP programs to define an internal table <name>.
A local type <name> that takes on the attributes of type TABTYPE can be defined in the program with TYPES <name> TYPE TABTYPE.
Reward if Helpful -
How to Send Internal table to SAP Spool using Function Modules or Methods?
Hi Experts,
How to Send Internal table to SAP Spool using Function Modules or Methods?
Thanks ,
KiranThis is my code.
I still get the no ABAP list data for the spool, even tho I can see it sp01?
REPORT Z_MAIL_PAYSLIP.
* Declaration Part *
tables: PERNR, PV000, T549Q, V_T514D, HRPY_RGDIR.
infotypes: 0000, 0001, 0105, 0655.
data: begin of ITAB occurs 0,
MTEXT(25) type C,
PERNR like PA0001-PERNR,
ABKRS like PA0001-ABKRS,
ENAME like PA0001-ENAME,
USRID_LONG like PA0105-USRID_LONG,
end of ITAB.
data: W_BEGDA like HRPY_RGDIR-FPBEG,
W_ENDDA like HRPY_RGDIR-FPEND.
data: RETURN like BAPIRETURN1 occurs 0 with header line.
data: P_INFO like PC407,
P_FORM like PC408 occurs 0 with header line.
data: P_IDX type I,
MY_MONTH type T549Q-PABRP,
STR_MY_MONTH(2) type C,
MY_YEAR type T549Q-PABRJ,
STR_MY_YEAR(4) type C,
CRLF(2) type x value '0D0A'.
data: W_CMONTH(10) type C.
data: TAB_LINES type I,
ATT_TYPE like SOODK-OBJTP.
data: begin of P_INDEX occurs 0,
INDEX type I,
end of P_INDEX.
constants: begin of F__LTYPE, "type of line
CMD like PC408-LTYPE value '/:', "command
TXT like PC408-LTYPE value 's', "textline
end of F__LTYPE.
constants: begin of F__CMD, "commands
NEWPAGE like PC408-LINDA value '',
end of F__CMD.
data: P_LIST like ABAPLIST occurs 1 with header line.
*data: OBJBIN like SOLISTI1 occurs 10 with header line,
data: OBJBIN like LVC_S_1022 occurs 10 with header line,
DOCDATA like SODOCCHGI1,
OBJTXT like SOLISTI1 occurs 10 with header line,
OBJPACK like SOPCKLSTI1 occurs 1 with header line,
RECLIST like SOMLRECI1 occurs 1 with header line,
OBJHEAD like SOLISTI1 occurs 1 with header line,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_buffer type string,
l_no_of_bytes TYPE i,
l_pdf_spoolid LIKE tsp01-rqident,
l_jobname LIKE tbtcjob-jobname.
data: file_length type int4,
spool_id type rspoid,
line_cnt type i.
*-------------------------------------------------------------------* * INITIALIZATION *
OBJBIN = ' | '.
append OBJBIN.
OBJPACK-HEAD_START = 1.
data: S_ABKRS like PV000-ABKRS.
data: S_PABRP like T549Q-PABRP.
data: S_PABRJ like T549Q-PABRJ.
* SELECTION SCREEN *
selection-screen begin of block BL1.
parameters: PAY_VAR like BAPI7004-PAYSLIP_VARIANT default 'ESS_PAYSLIPS' obligatory.
selection-screen end of block BL1.
START-OF-SELECTION.
s_ABKRS = PNPXABKR.
S_PABRP = PNPPABRP.
s_pabrj = PNPPABRJ.
w_begda = PN-BEGDA.
w_endda = PN-ENDDA.
get pernr.
* "Check active employees
rp-provide-from-last p0000 space pn-begda pn-endda.
CHECK P0000-STAT2 IN PNPSTAT2.
* "Check Payslip Mail flag
rp-provide-from-last p0655 space pn-begda pn-endda.
CHECK P0655-ESSONLY = 'X'.
rp-provide-from-last p0001 space pn-begda pn-endda.
* "Find email address
RP-PROVIDE-FROM-LAST P0105 '0030' PN-BEGDA PN-ENDDA.
if p0105-usrid_LONG ne ''.
ITAB-PERNR = P0001-PERNR.
ITAB-ABKRS = P0001-ABKRS.
ITAB-ENAME = P0001-ENAME.
ITAB-USRID_LONG = P0105-USRID_LONG.
append itab.
clear itab.
endif.
"SY-UCOMM ='ONLI'
END-OF-SELECTION.
*------------------------------------------------------------------* start-of-selection.
write : / 'Payroll Area : ', S_ABKRS.
write : / 'Payroll Period/Year : ',STR_MY_MONTH,'-',STR_MY_YEAR. write : / 'System Date : ', SY-DATUM.
write : / 'System Time : ', SY-UZEIT.
write : / 'User Name : ', SY-UNAME.
write : / SY-ULINE.
sort ITAB by PERNR.
loop at ITAB.
clear : P_INFO, P_FORM, P_INDEX, P_LIST, OBJBIN, DOCDATA, OBJTXT, OBJPACK, RECLIST, TAB_LINES.
refresh : P_FORM, P_INDEX, P_LIST, OBJBIN, OBJTXT, OBJPACK, RECLIST.
* Retrieve Payroll results sequence number for this run
select single * from HRPY_RGDIR where PERNR eq ITAB-PERNR
and FPBEG ge W_BEGDA
and FPEND le W_ENDDA
and SRTZA eq 'A'.
* Produce payslip for those payroll results
if SY-SUBRC = 0.
call function 'GET_PAYSLIP'
EXPORTING
EMPLOYEE_NUMBER = ITAB-PERNR
SEQUENCE_NUMBER = HRPY_RGDIR-SEQNR
PAYSLIP_VARIANT = PAY_VAR
IMPORTING
RETURN = RETURN
P_INFO = P_INFO
TABLES
P_FORM = P_FORM.
check RETURN is initial.
* remove linetype from generated payslip
loop at p_form.
objbin = p_form-linda.
append objbin.
line_cnt = line_cnt + 1.
endloop.
file_length = line_cnt * 1022.
* create spool file of paylsip
CALL FUNCTION 'SLVC_TABLE_PS_TO_SPOOL'
EXPORTING
i_file_length = file_length
IMPORTING
e_spoolid = spool_id
TABLES
it_textdata = objbin.
IF sy-subrc EQ 0.
WRITE spool_id.
ENDIF.
DESCRIBE table objbin.
DATA PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = spool_id
NO_DIALOG = ' '
DST_DEVICE = 'MAIL'
* PDF_DESTINATION =
* IMPORTING
* PDF_BYTECOUNT = l_no_of_bytes
* PDF_SPOOLID = l_pdf_spoolid
* LIST_PAGECOUNT =
* BTC_JOBNAME =
* BTC_JOBCOUNT =
TABLES
PDF = pdf
EXCEPTIONS
ERR_NO_ABAP_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DESTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11
OTHERS = 12
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*Download PDF file C Drive
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\itab_to_pdf.pdf'
filetype = 'BIN'
TABLES
data_tab = pdf.
* Transfer the 132-long strings to 255-long strings
* LOOP AT pdf.
* TRANSLATE pdf USING ' ~'.
* CONCATENATE gd_buffer pdf INTO gd_buffer.
* ENDLOOP.
* TRANSLATE gd_buffer USING '~ '.
* DO.
* it_mess_att = gd_buffer.
* APPEND it_mess_att.
* SHIFT gd_buffer LEFT BY 255 PLACES.
* IF gd_buffer IS INITIAL.
* EXIT.
* ENDIF.
* ENDDO.
OBJHEAD = 'Objhead'.
append OBJHEAD.
* preparing email subject
concatenate W_ENDDA(6)
' Payslip-'
ITAB-ENAME+0(28)
ITAB-PERNR+4(4) ')'
into DOCDATA-OBJ_DESCR.
DOCDATA-OBJ_NAME = 'Pay Slip'.
DOCDATA-OBJ_LANGU = SY-LANGU.
OBJTXT = 'Pay Slip.'.
append OBJTXT.
*prepare email lines
OBJTXT = DOCDATA-OBJ_DESCR.
append OBJTXT.
OBJTXT = 'Please find enclosed your current payslip.'.
append OBJTXT.
* Write Attachment(Main)
* 3 has been fixed because OBJTXT has fix three lines
read table OBJTXT index 3.
* DOCDATA-DOC_SIZE = ( 3 - 1 ) * 255 + strlen( OBJTXT ).
clear OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = 3.
OBJPACK-DOC_TYPE = 'RAW'.
append OBJPACK.
* Create Message Attachment
ATT_TYPE = 'PDF'.
describe table OBJBIN lines TAB_LINES.
read table OBJBIN index TAB_LINES.
* OBJPACK-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + strlen( OBJBIN ).
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = ATT_TYPE.
OBJPACK-OBJ_NAME = 'ATTACHMENT'.
OBJPACK-OBJ_DESCR = 'Payslip'.
append OBJPACK.
* Create receiver list refresh RECLIST.
clear RECLIST.
RECLIST-RECEIVER = itab-USRID_long.
translate RECLIST-RECEIVER to lower case.
RECLIST-REC_TYPE = 'U'.
append RECLIST.
* Send the document
*SO_NEW_DOCUMENT_ATT_SEND_API1
call function 'SO_DOCUMENT_SEND_API1'
exporting
DOCUMENT_DATA = DOCDATA
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
tables
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = pdf
CONTENTS_TXT = OBJTXT
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
RECEIVERS = RECLIST
exceptions
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
others = 8.
if SY-SUBRC NE 0.
ITAB-MTEXT = 'Message Not Sent to : '.
else.
ITAB-MTEXT = 'Message Sent to : '.
endif.
* else.
* ITAB-MTEXT = 'Message Not Sent to : '.
* endif.
else.
"SY-SUBRC Not = 0
ITAB-MTEXT = 'Payroll data not found : '.
endif.
"end of SY-SUBRC = 0.
modify ITAB.
endloop. "end loop at ITAB
sort ITAB by MTEXT PERNR.
loop at ITAB.
at new MTEXT.
uline.
write : / ITAB-MTEXT color 4 intensified on.
write : / 'Emp. Code' color 2 intensified on,
12 'Emp. Name' color 2 intensified on,
54 'Email ID' color 2 intensified on.
endat.
write : / ITAB-PERNR, 12 ITAB-ENAME, 54 ITAB-USRID_LONG.
endloop. -
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 -
hello,
how to refresh table display using slis and 'reuse_alv_grid_display method'.
when i'm refreshing table display it performs once again reuse_alv_grid_display.and when i back the previous value appear.how to solve it?
neonare you chaning any value in the gird if so use this..
Pass the user_command form name to the Import parameter
I_CALL_BACK_USERCOMMAND .
and have the Dynamic form implementation..
FORM user_command USING ucomm TYPE sy-ucomm
selfield TYPE slis_selfield.
"The below is important for Editable Grid.
DATA: gd_repid LIKE sy-repid, "Exists
ref_grid TYPE REF TO cl_gui_alv_grid.
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.
IF NOT ref_grid IS INITIAL.
CALL METHOD ref_grid->check_changed_data .
ENDIF.
CASE ucomm.
WHEN 'REFRSH'.
ENDCASE.
selfield-refresh = 'X'.
ENDFORM. "user_command -
How to use nested table types with XDK
Im using Oracles XDK (xml development kit) to create xml-documents from data in database.4
Problem: I need to use nested tables but when trying to create nested table types I get error: A Table type may not contain a nested table type or VARRAY.
Hope I make myself clear! Are there any solutions or workarounds to this problem?
Help appreciated, thanks!Jesper,
I asked similar question last year (search for Tapsell, you will see my posting). Under 8.1.7 the "nesting" seems restricted to one level down. Thus you cannot create a type using another object that itself includes a nested table. Under Oracle 9, against which most current examples seem based, this limitation is removed making things easier. Under 8.1.7 the workaround I have used is to use the CAST syntax. This is not as neat, but it works. -
How to use Oracle Table Type values in Select Statement.
Hi,
I am fetching initial set of values into Oracle Table of Records Type and want to use list of values in the Select statement.
For example, try something like the following:
TYPE t_record IS RECORD (
ID TABLEA.ID%type,
NO TABLEA.NO%type,
v_record t_record;
TYPE t_table IS TABLE OF v_record%TYPE;
v_table t_table;
-- Code to populate the values in v_table here.
SELEC ID,NO, BULK COLLECT INTO <some other table variabes here> FROM TABLEA
WHERE ID IN v_table(i).ID;
I want to know how to use the values from Oracle Table Type in the Select Statement.Something like this:
create or replace type t_record as object (
id number,
no number
CREATE or replace type t_table AS TABLE OF t_record;
set serveroutput on
declare
v_table t_table := t_table();
v_t1 t_table := t_table();
begin
v_table.extend(1);
v_table(1).ID := 1;
v_table(1).No := 10;
v_table.extend(1);
v_table(2).ID := 2;
v_table(2).ID := 20;
SELEC t_record (ID,NO) BULK COLLECT INTO v_t1
from TableA
FROM TABLEA
WHERE ID IN (select t.ID from table(v_Table) t);
for i in 1..v_t1.count loop
dbms_output.put_line(v_t1(i).ID);
dbms_output.put_line(v_t1(i).No);
end loop;
end;
/Untested!
P;
Edited by: bluefrog on Mar 5, 2010 5:08 PM -
How to use record type for inserting data into a table
I've read through the web the following tip:
"When working with a large number of columns, using variables of type RECORD is a better approach. With this approach, you do not have to list anything in the INSERT statement, because you are inserting a variable into the table that is defined as a row from the same table."
I usually define a variable as
r_mytable mytable%ROWTYPE;
and inside my procedure I'll set the fields I need as
r_mytable.field1 := 1;
r_mytable.field3 := 7;
and then I perform the insert as
insert into mytable
(field1,
field3)
values
(r_mytable.field1,
r_mytable.field3);
According to the tip I've copied above, how can I use the TYPE RECORD of pl/sql for achieving the same result but perhaps in a smarter way?
Thanks in advance!Hi,
Are you looking for this?
SQL> create table table1 (id number, descr varchar2(30));
Table created
SQL>
SQL> DECLARE
2 my_rec table1%rowtype;
3 BEGIN
4 my_rec.id := 1;
5 my_rec.descr := 'TEST';
6 insert into table1 values my_rec;
7 END;
8 /
PL/SQL procedure successfully completed
SQL> select * from table1;
ID DESCR
1 TESTWorks with UPDATE too :
SQL> DECLARE
2 my_rec table1%rowtype;
3 BEGIN
4 my_rec.id := 2;
5 my_rec.descr := 'TEST2';
6 update table1 set row = my_rec where id = 1;
7 END;
8 /
PL/SQL procedure successfully completed
SQL> select * from table1;
ID DESCR
2 TEST2
Maybe you are looking for
-
Certificate for server is Invalid ??
Hi, Never had a problem with my mail before, but suddenly seems to have completely screwed up. Every time i try to send something it says Mail was unable to verify the identity of this server, which has a certificate issued to "______". The error was
-
Problem with Creative Cloud Desktop App in Mavericks
I have posted a couple of times about this but no one seems to be answering. There seems to be a bug with the Creative Cloud Desktop app and Mac OS Mavericks. I have the newest version of them installed on a brand new MacBook Pro and I have had probl
-
Firefox minimizes itself and crashes - Windows 7
My Firefox 3.6.12 in my notebook when is minimized, for a little while, crashes itself and I can't maximize it. The program is shown on the Win7 taskbar. On the Windows task manager, FF appears like "working", but, if I press alt+tab or windows+tab,
-
How to match invoice with credit together
I am new to this forum. In EnterpriseOne Accounts Payable function, is it possible to bring up both invoice and credit memo, to match the net quantity in the receipt? For example, invoice charges 5 pcs, then credits back -2 pcs, the receipt has the n
-
LD416 (Ver4.2.5) specification content-rule
I have localdirector 416 with 4.2.5. How to define the rules for content load balancing with https. First of all, on specification Is it impossible? As the following content-rule rule01 depth 1024 "/aaa/" content-rule rule02 depth 1024 "/bbb/" virtua