How to get execution plan in a CLOB?
Hello,
I want to get execution plans of a query in a CLOB format. I am trying to run following query against v$sql view. One of the columns I want is the execution plan for the query. I am getting following error. Eventually, I am going to insert this data into a log table to keep history of all SQLs and their execution plans.
How can I do that?
Thank you in advance.
SQL> SELECT sql_id,
2 plan_hash_value,
3 TO_CLOB (DBMS_XPLAN.display_awr (sql_id => sql_id,
4 plan_hash_value => plan_hash_value,
5 format => '+PEEKED_BINDS'))
6 sql_plan_clob,
7 buffer_gets,
8 executions
9 FROM v$sql
10 WHERE ROWNUM < 5;
TO_CLOB (DBMS_XPLAN.display_awr (sql_id => sql_id,
ERROR at line 3:
ORA-00932: inconsistent datatypes: expected NUMBER got SYS.DBMS_XPLAN_TYPE_TABLE
try first
select *
from table(DBMS_XPLAN.display_awr(sql_id => sql_id,
plan_hash_value => plan_hash_value,
format => '+PEEKED_BINDS'
)to see the table returned
then try to adapt http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:68212348056 to produce fixed length rows.
look for describe_columns procedures in http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_sql.htm#i1025449 for column length information available in internal tables and write the rows directly to clob instead of writing to disk and loading your clob from there.
Regards
Etbin
Edited by: Etbin on 31.10.2012 19:56
pointing to dbms_sql package added
Similar Messages
-
How to get execution plan from plsql
i have a nasty sql inside plsql and want to get the execution plan. what is the best way of getting it.
v_sql:= 'select loop_f1.loopid
FROM rdw.WDM_Prov seg_f1,
rdw.WDM_loop_Prov_association assoc_f1,
rdw.WDM_potential_loop_makeup loop_f1,
rdw.WDM_Prov seg_fx,
rdw.WDM_loop_Prov_association assoc_fx,
TABLE(CAST( :loopInfo as ermarc.t_CustomerLoopElement)) input_loop
WHERE loop_f1.CO_illc = :f1_co_illc
AND loop_f1.LOOPID = assoc_f1.LOOPID
AND assoc_f1.Prov_NUMBER = :f1_Prov_number
AND assoc_f1.Prov_ID = seg_f1.Prov_ID
AND Upper(TRIM(LEADING 0 FROM seg_f1.CABLE)) =:f1_cable
AND (seg_f1.low_rep <= :f1_rep AND seg_f1.high_rep >= :f1_rep)
AND seg_f1.TERMSYSID = :f1_termsysid
AND assoc_f1.Prov_number = 1
AND loop_f1.loopid = assoc_fx.loopid
AND assoc_fx.Prov_ID = seg_fx.Prov_id
AND assoc_fx.Prov_number = input_loop.Prov_number
AND Upper(TRIM(LEADING 0 FROM seg_fx.CABLE)) = Upper(TRIM(LEADING 0 FROM input_loop.cable))
AND (seg_fx.low_rep <= input_loop.rep and seg_fx.high_rep >= input_loop.rep)
AND seg_fx.termsysid = input_loop.termsysid
GROUP BY loop_f1.loopid
HAVING MAX(assoc_fx.Prov_NUMBER) = :v_cntProvs
AND COUNT(CASE WHEN assoc_fx.Prov_number = input_loop.Prov_number THEN 1 ELSE 0 END) = :v_cntProvs';
EXECUTE IMMEDIATE v_sql BULK COLLECT INTO v_looplist
USING loopInfo,
loopInfo(1).co_illc,
loopInfo(1).Prov_number,
Upper(TRIM(LEADING 0 FROM loopInfo(1).cable)),
loopInfo(1).rep,
loopInfo(1).rep,
loopInfo(1).termsysid,
v_cntProvs,
v_cntProvs;Sorry, a tag or a statement_id is a way of identifying a particular SQL statement by an identifier other than its SQL_ID to make getting the plan easier. If I want the plans for two different statements, I can provide a statement_id and use that as an argument for DBMS_XPLAN later on.
SQL> ed
Wrote file afiedt.buf
1 begin
2 execute immediate
3 'explain plan set statement_id = ''JCAVE_DEPT'' for select * from dept'
4 execute immediate
5 'explain plan set statement_id = ''JCAVE_EMP'' for select * from emp';
6* end;
SQL> /
PL/SQL procedure successfully completed.
SQL> select *
2 from table( dbms_xplan.display( null, 'JCAVE_DEPT', null ));
PLAN_TABLE_OUTPUT
Plan hash value: 3383998547
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 4 | 120 | 3 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| DEPT | 4 | 120 | 3 (0)| 00:00:01 |
Note
PLAN_TABLE_OUTPUT
- dynamic sampling used for this statement
12 rows selected.
SQL> ed
Wrote file afiedt.buf
Wrote file afiedt.buf
1 select *
2* from table( dbms_xplan.display( null, 'JCAVE_EMP', null ))
SQL> /
PLAN_TABLE_OUTPUT
Plan hash value: 3956160932
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 14 | 1218 | 3 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| EMP | 14 | 1218 | 3 (0)| 00:00:01 |
Note
PLAN_TABLE_OUTPUT
- dynamic sampling used for this statement
12 rows selected.Justin -
How to get the planned quantity of past month from md61
Hi all,
I couldnt get the planned quantity of past month from the tcode md61.It shows only the current and future month's demand.I want to know the planned quantity of past month's.
I have checked PBIM,PBED,PBHI tables,here also I am facing the same problem.
Is it possible to get past month quantity from md61? If No how to know the quantity planned for past month?...Please tel your ideas..
Thanks in Advance!!!
Edited by: Ranganayahi Chandirasekaran on Jul 30, 2008 8:17 AMHi,
You can check History of PIR through MD62 itself.
Select particular row, Goto Menu, Select Item History(Shift +F6).
Or
You may pls execute transaction MD73.
Plz select option "3 :History Planned ind reqmnts " in the display options and execute the report.
Regards,
R.Brahmankar -
How to create execution plan in DAC and how to start ETL steps
Hi,
For ETL configuration i have installed and configured,
1. Oracle 10G DB
2. obiee and obia 7.9.6
3. informatica server (here i created repository and integration services)
4. DAC server 10g (setup for DAC is also configured like create warehouse tables etc.,
same installation done on windows for client.
Now i'm struck with execution plan creation.
then
how to start ETL, where start ETL
Source : Oracle EBIZ R12.1.1
target : Datawarehouse (10G DB)
please help me out the steps till ETL start ?
Thanks,
SrikHi Srik
I am assuming you have followed the steps required before a load in the library for dac config, csv lookups etc...
Did you check out the example in the documentation?
Here is the link
http://download.oracle.com/docs/cd/E14223_01/bia.796/e14217/windows_ic.htm#BABFGIHE
If you follow those steps and run the execution plan and you can monitor the progress under the current run tab in the dac and the infa workflow monitor.
Regards
Nick
Edited by: Nickho on 2010/06/21 9:24 AM -
I would like to know how to get the execution object to pass into the ActiveX/COM method Step.GetRunModeEx.
Hey Snood1,
There are other posts about this out there but as far as information in the released documentation it is kinda vague as to the fact that you can simply put any data type there. The definition states "Data type that can hold any defined type of data" But I can see the confusion that you don't have to actually convert it to a variant first. Generally you do have to convert it first. However some TestStand functions will allow any datatype and convert it for you.
Jon is going to create a Knowledge Base regarding this information and hopefully alleviate some of the pain for others in the future.
Regards,
jigg
CTA, CLA
teststandhelp.com
~Will work for kudos and/or BBQ~ -
How to get 2011 PLANS in TEVEN?
Hi
I have this problem that i need to populate the position field in TEVEN table. Users can do that from SE30->2011 and edit the position there. but that doesn't refeclt the TEVEN position field even though there are two position field in there (i am not sure why there r two of them). Can any one point me to the documentaion or some thing which will give me some idea how to make the link or relation between 2011 screen and TEVEN table. so that when the users change the position from 2011 screen that will also populate or change one of the position field in TEVEN.
Please help.
Thanks
Message was edited by:
Anwarul Kabir
Message was edited by:
Anwarul KabirI have found out so far that the field from the 2011 screen saves the data to P2APL-PLANS. But what's the relation between TEVEN and this structure? how do i get the data from P2APL?
Message was edited by:
Anwarul Kabir -
How to get the plan I originally signed up?
Hi,
This is such a nightmare and long long story. When iphone 6 came out last month, I upgraded my old phone and signed up for More Everything plan with the 10gb data for $80 in the store plus for each phone I get 1 gb free data per upgraded smartphone (I have 3 lines that were upgraded). At first, the sales rep said he can't make a change to my account until all my phones are activated. I told him it will be all activated by tonight. He said he will ensure to get my account change later today or tomorrow and I do not need to worry. I went back to him the next day to tell him and again I was given the same **.
A week later, I called 611 to make sure my plan did change but the rep said he did not see any change on the account and he'd be happy to sign me up for the More Everything and their current promo for the 10gb data for $80 plus the 1gb free per line so a total of 3gb. After on the phone with the rep for over 45 mins and confirmed everything to make sure I have the plans setup and all. He said my $80 10gb data plan will stay as long as I have the plan and no changes to my account and that my new plan will go in effect on my next billing cycle which is 10/18. I trusted his words and think he put it through.
On 10/20, my husband logged into verizonwireless.com to doublecheck and nothing was change. Very disappointing so I called 611 again. This time I was told that my plan didn't kick in and that they no longer offer that $80 10gb plus the 1gb free data for upgrading. I am sooooo upset after what I went through. On top, I found out that one of my line that I was trying to disconnect for a month did not disconnect and I am still paying for it. Even more upsetting.
What I want right now is someone get me the data plan I was promised. I can't believe I trusted Verizon reps and salesperson for everything but for nothing. On top, I am now stuck with Verizon for 2 years since I just upgraded. I was a loyal Verizon customers for like 10 years and this is what I get?????? I hardly ever make a change in plan and I got screwed up big time. I am unable to lock in the rate I was promised.
Verizon you guys are horrible. At this point, if I have a choice, I am leaving you guys.Really sorry to hear that. If they cant follow through with what was promised then it might be time to say no thank you and try another provider. I am currently dealing with a dispute with them where I took my phone in for the trade in program and they lost the phone and now I'm unable to get my credit. Plus, they have the nerve to lie to me in my face and say they never took it and they cannot be held responsible. Filed the complaint earlier today.
-
How to get active plan version dynamically
Hi all,
I am making some HR reports in which I am pulling up position long text from hrp1001 by giving condition - where plavr = '01' . Now if the active plan version is not 01, my condition becomes vague.
Please let me know how to determine the active plan version dynamically in my sample code below
SELECT APERNR AOTYPE B~STEXT INTO CORRESPONDING FIELDS OF TABLE ITAB_EMP_DEATILS3 FROM PA0001 AS A
INNER JOIN HRP1000 AS B ON BOTYPE = AOTYPE AND BOBJID = APLANS WHERE ( BOTYPE = 'S' AND BPLVAR = '01' AND AENDDA = '99991231' AND BENDDA = '99991231') AND A~PERNR IN PNPPERNR.
SORT ITAB_EMP_DEATILS3 BY PERNR.
DELETE ADJACENT DUPLICATES FROM ITAB_EMP_DEATILS3.Simply call FM RH_GET_PLVAR
-
How to get the PLANNING SHORTAGE in the forecast tab of /sapapo/rrp3?
Hi to all!
I need your help!
I'd like to take the planning shortage quantities in the forecast tab of the product view /sapapo/rrp3 and the related date and I'd like to insert that quantity on the 9AAFCST key figure in the related time bucket.
Have you got any idea on how to go on?
Thanks a lot!
MariaThis is now possible in the LIO solution pack available in extensibility pack 3.4 And above. You can read more about it on OTN, LIO solution pack guide. There is also a training overview recording available on the collaboration sites.
-
How to get second plan CC ?
I have CC for photographers(student) I want to get a second plan CREATIVE CLOUD COMPLETE
- when i press "buy now" it says that i have already a plan register and don't let me get a new plan?
can anybody help me pleasewhat is in the entire Cloud http://www.adobe.com/creativecloud/catalog/desktop.html
-
How to get cost plan value in tcode 'CJ40'
Hi guys,
Run tcode 'CJ40', user can input the cost in WBS element (in the 'cost plan' column).
Now the requirement is that , we should get the value from this column and I have find some functions. But all don't work.
So seek help from you experts.
Welcome any suggestion!.
Thanks very much!!Refer COSS, COEP and COSP tables for actual and plan costs.
Thanks,
Santosh -
How to get GL plan value plant wise
Hello,
Can you tell anybody where to updated GL plan value plant wise. In GP12N there is no planner profile for plant wise.
Thanks & reagrds,
Preethi kadkolHi,
Go toT.code FAGLL03 (GL Account Line Item Display G/L View).You Select the Custom Selections (Ctrl+F1) Button and there In GL Account Line Items select Plant and Click on Copy Selected Button at the bottom and provide the Plant Details and Saveyou have an option to change the layout and select the available fields in the layout. Plant and have it in the line items report, provided you maintain it as a special field using T. Code: OBVU/O7R3 (Line layaout variant for special fields).
Thanks,
Raviteja -
How to get execution time for a view inside procedure ?
Hi,
I want execution time for all the views in my database. I tried "execute immediate" but it does not seem to work.
It is not waiting to complete the execution of view to go to next step.
If I am executing the same statement in sqlplus, it is displaying correct time.
Here is my code:
Begin
output_file := UTL_FILE.FOpen ('RECORDING',v_FileName, 'W', 32767);
Open viewcur;
Loop
Fetch viewcur into v_view_name;
Exit when viewcur%notfound;
SELECT to_char(systimestamp,'DD-MON-YYYY HH24:MI:SS.FF') into v_start_time from dual;
v_stmt := 'Select * from ' ||v_view_name ;
Execute Immediate v_stmt;
SELECT to_char(systimestamp,'DD-MON-YYYY HH24:MI:SS.FF') into v_end_time from dual;
v_record_str := v_start_time||','||v_view_name||','||v_end_time;
UTL_FILE.PUT_LINE(output_file, v_record_str);
End Loop;
Close viewcur;
utl_file.fClose(output_file);
End ;
Oracle version: 11.1.0.6.0Hi,
Running with a user with dba privileges:
DECLARE
CURSOR viewcur IS
SELECT table_name
FROM dictionary d
WHERE d.table_name LIKE 'ALL_A%';
output_file UTL_FILE.file_type;
v_FileName VARCHAR2(30) := 'TEST_VIEW_TIME.TXT';
v_view_name dictionary.table_name%TYPE;
v_start_time varchar2(30);
v_end_time varchar2(30);
v_record_str varchar2(200);
v_stmt varchar2(200);
BEGIN
output_file := UTL_FILE.FOpen('EXT_FILES', v_FileName, 'W', 32767);
OPEN viewcur;
LOOP
FETCH viewcur
INTO v_view_name;
EXIT WHEN viewcur%NOTFOUND;
SELECT TO_CHAR(systimestamp, 'DD-MON-YYYY HH24:MI:SS.FF')
INTO v_start_time
FROM dual;
v_stmt := 'Select * from ' || v_view_name;
EXECUTE IMMEDIATE v_stmt;
SELECT TO_CHAR(systimestamp, 'DD-MON-YYYY HH24:MI:SS.FF')
INTO v_end_time
FROM dual;
v_record_str := v_start_time || ',' || v_view_name || ',' || v_end_time;
UTL_FILE.PUT_LINE(output_file, v_record_str);
END LOOP;
CLOSE viewcur;
utl_file.fClose(output_file);
END;
/TEST_VIEW_TIME.TXT:
02-JUL-2009 11:48:47.953000,ALL_ARGUMENTS,02-JUL-2009 11:48:47.953000
02-JUL-2009 11:48:47.953000,ALL_ALL_TABLES,02-JUL-2009 11:48:47.953000
02-JUL-2009 11:48:47.953000,ALL_ASSOCIATIONS,02-JUL-2009 11:48:47.953000
02-JUL-2009 11:48:47.953000,ALL_AUDIT_POLICIES,02-JUL-2009 11:48:47.999000
02-JUL-2009 11:48:47.999000,ALL_AUDIT_POLICY_COLUMNS,02-JUL-2009 11:48:48.093000
02-JUL-2009 11:48:48.093000,ALL_AWS,02-JUL-2009 11:48:48.187000
02-JUL-2009 11:48:48.187000,ALL_AW_PS,02-JUL-2009 11:48:48.187000
02-JUL-2009 11:48:48.187000,ALL_APPLY,02-JUL-2009 11:48:48.343000
02-JUL-2009 11:48:48.343000,ALL_APPLY_PARAMETERS,02-JUL-2009 11:48:48.421000
02-JUL-2009 11:48:48.421000,ALL_APPLY_KEY_COLUMNS,02-JUL-2009 11:48:48.437000
02-JUL-2009 11:48:48.437000,ALL_APPLY_CONFLICT_COLUMNS,02-JUL-2009 11:48:48.781000
02-JUL-2009 11:48:48.781000,ALL_APPLY_TABLE_COLUMNS,02-JUL-2009 11:48:48.828000
02-JUL-2009 11:48:48.828000,ALL_APPLY_DML_HANDLERS,02-JUL-2009 11:48:48.890000
02-JUL-2009 11:48:48.890000,ALL_APPLY_PROGRESS,02-JUL-2009 11:48:48.968000
02-JUL-2009 11:48:48.968000,ALL_APPLY_ERROR,02-JUL-2009 11:48:49.015000
02-JUL-2009 11:48:49.015000,ALL_APPLY_ENQUEUE,02-JUL-2009 11:48:49.234000
02-JUL-2009 11:48:49.234000,ALL_APPLY_EXECUTE,02-JUL-2009 11:48:49.281000
02-JUL-2009 11:48:49.281000,ALL_AW_PROP,02-JUL-2009 11:48:49.531000
02-JUL-2009 11:48:49.546000,ALL_AW_OBJ,02-JUL-2009 11:48:49.578000
02-JUL-2009 11:48:49.578000,ALL_AW_PROP_NAME,02-JUL-2009 11:48:49.609000
02-JUL-2009 11:48:49.609000,ALL_AW_AC,02-JUL-2009 11:48:49.624000
02-JUL-2009 11:48:49.624000,ALL_AW_AC_10G,02-JUL-2009 11:48:49.640000Regards, -
How do i see query EXECUTION PLAN
Dear Experts ,
I'm using Toad, PL/SQL developer and working on very big query but its response is very slow could u please guide any one HOW I SEE EXECUTION PLAN of query to optimize further.
Faheem Latif
NetSol Technologies Limited Pakistan.
www.netsoltek.com, www.leasesoft.bizDear ,
Thank's for reply but it is showing this error.
"ORA-02404: specified plan table not found"
Faheem Latif
NetSol Technologies Limited Pakistan.
www.netsoltek.com, www.leasesoft.biz -
How enable the explain plan in JDeveloper?
Can you tell me how to get explain plan in JDeveloper?
Thanks in advance.If you are using jdev 11 just open a sql work sheet, type in your statement or query and hit F6 (Execute Explain Plan) or the third button from the right in the work sheet toolbar.
Timo
Maybe you are looking for
-
GUI_DOWNLOAD with WK1 File format
Hi All, I am using GUI_DOWNLOAD to download into xls file with "WK1" format. My Internal table that is passed to FM has 155 columns.But in the output file i can see only 99 columns. Is there ia restriction to download the number of columns in xls fil
-
Please help- Audio Cd won't mount after Update to 10.3.9
My CD/DVD drive is MATSHITA CD-RW CW-8122. Data CDs and DVDs are mounting fine. However when I put in an audio cd it clicks a few times and soonafter ejects. Everything was fine as far as I can remember before my update to 10.3.9 (from 10.3.5, I thin
-
I am having a problem with a query that I am executing as a Prepared Statement... I am using ? and PreparedStatement.setXXX to bind all non-constant variables in the query. Everything executes fine until I put an order by clause at the end. When I ad
-
How do I get I feel lucky to work in the address bar on Mac OSX?
In windows firefox I can just put espn in the toolbar and it finds the site, but in Mac firefox it directs me to ask.com. How can I change this?
-
Must I uninstall fennec 1.1 before installing the beta?