Explain Plan Error
Hi All,
I am using oracle 10g and running in sql*plus.
I am getting one error when running explain plan for one query, if I am running the query in sql*plus then it is working fine.
Query:- SELECT sp.store_cd wr_store_cd, l.store_cd, l.loc_cd, l.loc_tp_cd,
sp.pd_cd, MIN(sp.priority), MIN(sp.ck_showroom)
FROM store$pri sp, loc l
WHERE l.store_cd BETWEEN NVL(sp.beg_store_cd,' ') AND sp.end_store_cd
AND l.loc_cd BETWEEN NVL(sp.beg_loc_cd,' ') AND sp.end_loc_cd
AND l.pick = 'Y'
GROUP BY sp.store_cd, sp.pd_cd, l.store_cd, l.loc_cd, l.loc_tp_cd
ORDER BY wr_store_cd, pd_cd, MIN(priority), l.store_cd;
Syntax:- Explain plan for (SELECT sp.store_cd wr_store_cd, l.store_cd, l.loc_cd, l.loc_tp_cd,
sp.pd_cd, MIN(sp.priority), MIN(sp.ck_showroom)
FROM store$pri sp, loc l
WHERE l.store_cd BETWEEN NVL(sp.beg_store_cd,' ') AND sp.end_store_cd
AND l.loc_cd BETWEEN NVL(sp.beg_loc_cd,' ') AND sp.end_loc_cd
AND l.pick = 'Y'
GROUP BY sp.store_cd, sp.pd_cd, l.store_cd, l.loc_cd, l.loc_tp_cd
ORDER BY wr_store_cd, pd_cd, MIN(priority), l.store_cd);
I am getting the error :-
ORDER BY wr_store_cd, pd_cd, MIN(priority), l.store_cd)
ERROR at line 8:
ORA-00907: missing right parenthesis;
Any Idea.
Regards
SUN
I'm able to reproduce your situation like this:
SQL> explain plan
2 for
3 ( select d.deptno
4 , d.dname
5 , count(e.empno)
6 from emp e
7 , dept d
8 where e.deptno (+) = d.deptno
9 group by d.deptno
10 , d.dname
11 order by count(e.empno) desc
12 )
13 /
order by count(e.empno) desc
FOUT in regel 11:
.ORA-00907: missing right parenthesisAnd it seems to be because of the brackets inside the order by clause:
SQL> explain plan
2 for
3 ( select d.deptno
4 , d.dname
5 , count(e.empno)
6 from emp e
7 , dept d
8 where e.deptno (+) = d.deptno
9 group by d.deptno
10 , d.dname
11 -- order by count(e.empno) desc
12 )
13 /
Uitleg is gegeven.But you really do not need the brackets around your SQL statement in an explain plan. So I would just remove these:
SQL> explain plan
2 for
3 select d.deptno
4 , d.dname
5 , count(e.empno)
6 from emp e
7 , dept d
8 where e.deptno (+) = d.deptno
9 group by d.deptno
10 , d.dname
11 order by count(e.empno) desc
12 /
Uitleg is gegeven.Although normally speaking, brackets don't impose problems:
SQL> explain plan for select * from emp
2 /
Uitleg is gegeven.
SQL> explain plan for (select * from emp)
2 /
Uitleg is gegeven.Hope this helps.
Regards,
Rob.
Similar Messages
-
Explain plan error - How do I modify the code ?
Can someone tell me why it is not letting me run explain plan on this ?
SQL> explain plan for
2 SELECT idet.asset_id, DECODE (SIGN (idet.balance),
3 -1, 1,
4 2
5 ) AS debit_credit, TRUNC (from_dte)
6 AS from_dte,
7 idet.rate, idet.ccy, TRUNC (idet.value_dte) AS value_dte
8 FROM k$interests_jobs_details idet
9 WHERE idet.asset_id = :b3
10 AND idet.ccy = :b2
11 AND idet.asset = 1
12 AND idet.from_dte <= :b1
13 AND idet.from_dte >=
14 NVL ((SELECT TRUNC (MAX (idet2.from_dte))
15 FROM k$interests_jobs_details idet2
16 WHERE idet2.asset_id = :b3
17 AND idet2.ccy = :b2
18 AND idet2.asset = 1
19 AND idet2.from_dte <= TRUNC (:b4)
20 AND DECODE (SIGN (idet2.balance), -1, 1, 2) =
21 DECODE (SIGN (idet.balance),
22 -1, 1,
23 2
24 )),
25 idet.from_dte
26 )
27 GROUP BY idet.asset_id,
28 DECODE (SIGN (idet.balance), -1, 1, 2),
29 idet.rate,
30 idet.ccy,
31 idet.from_dte,
32 idet.value_dte
33 ORDER BY DECODE (SIGN (balance), -1, 1, 2) DESC, from_dte, value_dte DESC;
AND idet2.from_dte <= TRUNC (:b4)
ERROR at line 19:
ORA-00932: inconsistent datatypes: expected DATE got NUMBERJust to add to this - all bind variables in a explain plan are considered as varchar2 - regardless of how you define the bind variables.
SQL> var x number
SQL> explain plan for
2 select 'x' from dual where 1 = :x
3 /
Explained.
SQL> select * from table(dbmS_xplan.display)
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 731024556
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2 (0)| 00:00:01 |
|* 1 | FILTER | | | | |
| 2 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
1 - filter(TO_NUMBER(:X)=1)
SQL> See although I defined x as a number - in the plan it does an implicit conversion because it assumes it's a varchar2 variable ( filter(TO_NUMBER(:X)=1) )
Edited by: Lakmal Rajapakse on 08-Mar-2010 06:09 -
ORA-01745 when running Explain Plan
Hello everybody,
I would like to know what is the best way to report a bug. In fact I believe just found one and I would like it fixed. I am using the latest version of SQLDeveloper on WinXP that uses its own JDK.
To replicate the bug it's very easy, just try to do an explain plan of the following query:
SELECT * FROM scott.emp
where empno = &&emp_nr;and the "*ORA-01745: invalid host/bind variable name*" error appears. Since the query executes properly, but the Explain plan errors out, I believe this could be a bug.
Thanks,
PaoloGary,
thanks a lot for your feedback.
I have found this weird behaviour, because I was trying to avoid another one. In fact I tried using the substitution variable syntax instead of the bind variable syntax in SQLDeveloper, especially to avoid the issues coming from automatic data conversions.
For example, if I run the following query using the bind variable syntax (passing SYSDATE as the parameter value):
SELECT *
FROM scott.emp
WHERE hiredate BETWEEN TRUNC(:p_eff_date,'yyyy')
AND TRUNC(add_months(:p_eff_date,12),'yyyy') - 1;it will go in error with "*ORA-00932: inconsistent datatypes: expected DATE got NUMBER*", because the filter predicate will be converted automatically as follows:
TRUNC(TO_NUMBER(:P_EFF_DATE),TO_NUMBER('yyyy'))<=TRUNC(ADD_MONTHS(:P_EFF_DATE,12),'fmyyyy')-1This behaviour is visible by running the explain plan on the above query. Isn't that TO_NUMBER(:P_EFF_DATE),TO_NUMBER('yyyy') a little bit too wrong? Note that the second occurrence of the P_EFF_DATE parameter does not get converted. Can't this "automatic conversion" behaviour be disabled somehow?
Due to this weird issue I tried to use the substitution variable syntax, but the main issue with the single ampersand is that you have to enter the value of the parameter as many times as the parameter is referenced in the query and you can imagine that with big queries written by other people this is not so easy.
Is there another way to pass parameters to a query in the SQL Worksheet? How can I "use literals rather than variables" as you suggest? Do you mean NOT using parameters at all?
Thanks,
Paolo -
Hi when i run this in toad for explain plan its showing an error ORA_22905
hi when i run this query in toad for explain plan its showing an error ORA_22905 cannot accesss rows from an non nested table item can anyone help me out
SELECT
DISTINCT SERVICE_TBL.SERVICE_ID , SERVICE_TBL.CON_TYPE, SERVICE_TBL.S_DESC || '(' || SERVICE_TBL.CON_TYPE || ')' AS SERVICE_DESC ,SERVICE_TBL.CON_STAT
FROM
TABLE(:B1 )SERVICE_TBL
WHERE
CON_NUM = :B2
thanksNote the name of this forum is SQL Developer *(Not for general SQL/PLSQL questions)* (so for issues with the SQL Developer tool). Please post these questions under the dedicated SQL And PL/SQL forum.
Regards,
K. -
ERROR: insufficient privileges while using EXPLAIN PLAN command
Hi,
I have a table named TEST and i ran following command on this table.
SQL> EXPLAIN PLAN FOR
2 SELECT NAME FROM TEST;
SELECT NAME FROM TEST
ERROR at line 2:
ORA-01031: insufficient privileges
So which privilege do i need to give for using EXPLAIN PLAN command.
Thank.http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14211/ex_plan.htm#i19260
SQL> @C:\oracle\product\10.2.0\db_1\RDBMS\ADMIN\utlxplan.sql
Table created.
SQL> select table_name from user_tables where table_name='PLAN_TABLE';
TABLE_NAME
PLAN_TABLE
You might consider checking dba_tables to check the owner in your case and may be you don't privilege on that table. -
Hello,
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Productio
NLSRTL Version 10.2.0.4.0 - Production
I have this issue:
On the sited above database first I execute a SELECT query, no matter what is it, with EXPLAIN PLAN FOR:
EXPLAIN PLAN FOR SELECT <some query comes here>This executes successfully.
Next, I do this to see the explain plan:
SELECT *
FROM TABLE (dbms_xplan.display());This generates the following error, which I read from the column "PLAN_TABLE_OUTPUT" of the result set:
ERROR: an uncaught error in function display has happened; please contact Oracle support
Please provide also a DMP file of the used plan table PLAN_TABLE
ORA-00904: "OTHER_TAG": invalid identifierI see that it is said to contact Oracle support, but unfortunately in this firm I am not in position to contact Oracle, when there is an issue.
Probably it is obvious to most of you, but since I receive this error for first time, I am wondering where the reason for the error could be.
The table PLAN_TABLE exists, which I know is needed to hold the output of an EXPLAIN PLAN statement.
Generally, in this database, when I try to see the explain plan for any query, the plan shows no values for niether parameter: Cost, CPU Cost, I/O Cost, Cardinality, whatever.
Could anyone presume, what could be changed in order the problem to be fixed.
What else .. the reason is not into the tool I am using, which is PL/SQL Developer, version 7.1.5, because for other databases there is no problem with EXPLAIN PLAN.
Thanks.You have an invalid PLAN_TABLE that has been created by some utility or has come from a script from a lower version.
See the script $ORACLE_HOME/rdbms/admin/catplan.sql for the correct 10.2.0.4 PLAN_TABLE (script executed by SYS AS SYSDBA)
Alternatively, use $ORACLE_HOME/rdbms/admin/utlxplan.sql to create a private PLAN_TABLE
Hemant K Chitale -
Explain plan--Object not found error
Hi All,
I want to use 'explain plan' to optimise the query.
How do i see the explain plan in toad.
when i say
explain plan set statement_id='XX' for select stmt;
select * from explain plan
where statement_id='XX';
iam geeting object not found
what parameters i need to set up before using explain plan
Please give me details.
Please suggest.
Thanks.This should have been in TOAD Forum :-)).. Anyway,
You need to set the plan table name in view->Options->Oracle. If the specified plan table doesnt exist, create the plan table -
What are the privileges required for explain plan in Oracle 11g database
I am facing the problem in doing a explain plan for a view in Oracle 11g database. When I select from the view like this:
select * from zonewisearpu
It does a select on the view but when I give explain plan like
explain plan for
select * from zonewisearpu
I get the error like insufficient privileges.
Please let me know if things are getting missed out as I guess system level privileges are required to execute this.
I hope, my question is clear.
It’s a humble request to revert urgently if possible as I need to complete a task and do not know the way out.
Regards975148 wrote:
Thanks for your reply. I have found out that an explain plan is possible on the user's own objects and is not possible on the granted objects from a different schema. For eg, if I do a explain plan on a view querying on tables from a different view, it would not allow the explain plan to proceed. This could mean that explain plan needs different privileges than just a select.
Requesting for a revert to this.
Here is a simple test case that I have perfomed
SQL> create user test1 identified by test1;
User created.
SQL> create user test2 identified by test1;
User created.
SQL> grant connect, resource to test1,test2;
Grant succeeded.
SQL> create table test1.tab1 as select * from v$session;
Table created.
SQL> connect test2/test1
Conencted.
SQL> show user
USER is "TEST2"
SQL>
SQL> explain plan for
2 select sid,serial#,status,username from test1.tab1 where username<> '';
Explained.
SQL>
So, as can be seen I am able to do a explain plan from user test2 for tables belong to user test1.
As far as privileges are concerned, following is the list
SQL> select * from dba_role_privs where grantee in ('TEST1','TEST2') order by 1;
GRANTEE GRANTED_ROLE ADM DEF
TEST1 CONNECT NO YES
TEST1 RESOURCE NO YES
TEST2 CONNECT NO YES
TEST2 RESOURCE NO YES
SQL>
SQL> select grantee,owner,table_name,privilege from dba_tab_privs where grantee in ('TEST1','TEST2') order by 1;
GRANTEE OWNER TABLE_NAME PRIVILEGE
TEST2 TEST1 TAB1 SELECT
SQL>
SQL> select * from dba_sys_privs where grantee in ('TEST1','TEST2') order by 1;
GRANTEE PRIVILEGE ADM
TEST1 UNLIMITED TABLESPACE NO
TEST2 UNLIMITED TABLESPACE NO
SQL> -
I am trying to use TOAD to find the query performance. When I clicked on explain plan tab i get an error message: ORA-02404: specified plan table not found.
Can some one please tell me how to proceed from here so that I can check the explain plan for this tableI don't know how TOAD works with EXPLAIN PLAN, but mybe it is if you have PLAN_TABLE created in your database and granted all on it to public.
SQL> @<ORACLE_HOME>/rdbms/admin/utlxplan.sql
SQL> create public synonym plan_table for plan_table
SQL> grant all on plan_table to public
I don't know if you're looking for somethinkg like that ... -
Ora-01039 - Insuffficient priviliges - Tuning using Explain Plan
In a TEST instance, i am trying (as the APPS user) on a 9.2.0.5 DB (11.5.10.2) trying to run an explain plan on a query but keep getting the 'ora-01039 - Insuffficient privileges on underlying objects of view' error message.
I have granted 'select any dictionary' to both the APPS and APPLSYS users - but this does not seem to enable the explain plan to work.
Could someone please shed some light on this?
TksYou seem to be doin an Explain Plan on a query against a custom view against non-Apps objects.
Explain Plan needs to be able to "see" the underlying tables (in that other schema).
See :
SQL> create view his_cntry_vw as select * from my_cntry;
View created.
SQL> grant select on his_cntry_vw to abc;
Grant succeeded.
SQL> connect abc/abc
Connected.
SQL> create synonym his_cntry_vw for otheruser.his_cntry_vw;
Synonym created.
SQL> select * from his_cntry_vw;
GRP_I CNTRY
ABC Z9
XYZ UK
SQL> explain plan for select * from his_cntry_vw;
explain plan for select * from his_cntry_vw
ERROR at line 1:
ORA-01039: insufficient privileges on underlying objects of the view
SQL> REM THIS IS THE FIX :
SQL> connect otheruser/otheruser
Connected.
SQL> grant select on my_cntry to abc;
Grant succeeded.
SQL> connect abc/abc
Connected.
SQL> explain plan for select * from his_cntry_vw;
Explained.
SQL>Hemant K Chitale
http://hemantoracledba.blogspot.com -
Invalid column name when executing explain plan
SQL Developer version 4.0, SQL Worksheet, Windows 2000, Database 9.2.0.6.
When attempted to run a explain plan on a simple two table join query, it generates error invalid column name. Removed aliases and simplify query to one table row count, and still get the same error. Even tried the schema owner and got the same error.
I decided to check the explain plan table and found out that it was from an older version. Recreated the explain plan table and was able to run the explain plan.
I'm just posting this in the event somebody else runs into the same problem.This was fixed in the 4.1 or 1215 build. Please update by downloading or check for updates.
-thanks
kris -
I have done 'explain plan' for this query:-
explain plan for
select MD.* from ppbs_mobile_detail MD, ppbs_inv_sim_serial ISS where MD.LATEST_SIM_SERIAL_NO=ISS.SIM_SERIAL_NO
and MD.MOBILE_NO=ISS.MOBILE_NO
which is having indexes on all the four columns of the 2 tables used: LATEST_SIM_SERIAL_NO,SIM_SERIAL_NO,MOBILE_NO,
MOBILE_NO.
But only 1 index on mobile no. of ppbs_mobile_detail is firing.
Is that, indexes on only 1 table should fire.
I hope, my question is clear. Please help in solving the doubt.
Regards.thanks for ur update.
i tried, @?/rdbms/admin/utlxplan.sql but it was giving a error like 'unable to open file "?/rdbms/admin/utlxplan.sql"'.
So, i re-created the table.
I gave both the analyze statements,
SQL> analyze table PPBS_INV_SIM_SERIAL compute statistics for table for all indexed columns for all indexes ;
SQL> analyze table PPBS_MOBILE_DETAIL compute statistics for table for all indexed columns for all indexes ;
Output of select * from TABLE(dbms_xplan.display) is:-
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 1 | 164 | 21174 |
| 1 | HASH JOIN | | 1 | 164 | 21174 |
| 2 | TABLE ACCESS FULL | PPBS_INV_SIM_SERIAL | 3221K| 86M| 9772 |
| 3 | TABLE ACCESS FULL | PPBS_MOBILE_DETAIL | 1469K| 190M| 2718 |
Note: cpu costing is off, PLAN_TABLE' is old version
regards. -
Explain Plan not working with 919, was working with 804
Hi,
Explain Plan (F6) was working cprrectly with Raptor 804 and is not working any more on 919. This is the same query exactly (select * from mytable). The server is 9.2.0.5.0. The result with 919 is "Invalid Column Name".
Regards
EricI get this too.
The plan table structure is
CREATE TABLE "ELX"."PLAN_TABLE"
( "STATEMENT_ID" VARCHAR2(30),
"TIMESTAMP" DATE,
"REMARKS" VARCHAR2(80),
"OPERATION" VARCHAR2(30),
"OPTIONS" VARCHAR2(30),
"OBJECT_NODE" VARCHAR2(128),
"OBJECT_OWNER" VARCHAR2(30),
"OBJECT_NAME" VARCHAR2(30),
"OBJECT_INSTANCE" NUMBER,
"OBJECT_TYPE" VARCHAR2(30),
"OPTIMIZER" VARCHAR2(255),
"SEARCH_COLUMNS" NUMBER,
"ID" NUMBER,
"PARENT_ID" NUMBER,
"POSITION" NUMBER,
"COST" NUMBER,
"CARDINALITY" NUMBER,
"BYTES" NUMBER,
"OTHER_TAG" VARCHAR2(255),
"PARTITION_START" VARCHAR2(255),
"PARTITION_STOP" VARCHAR2(255),
"PARTITION_ID" NUMBER,
"OTHER" LONG,
"DISTRIBUTION" VARCHAR2(30)And raptor seems to be issuing this
PARSING IN CURSOR #2 len=82 dep=0 uid=80 oct=50 lid=80 tim=3808125826 hv=1796199517 ad='17ebc98c'
EXPLAIN PLAN SET STATEMENT_ID ='4363' INTO PLAN_TABLE FOR select * from collection
END OF STMT
PARSE #2:c=0,e=742,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=4,tim=3808125815
BINDS #2:
=====================
PARSE ERROR #3:len=480 dep=1 uid=80 oct=2 lid=80 tim=3808128369 err=904
insert into "PLAN_TABLE" (statement_id, timestamp, operation, options,object_node, object_owner, object_name, object_instance, object_type,search_columns, id, parent_id, position, other,optimizer, cost, cardinality, bytes, other_tag, partition_start, partition_stop, partition_id, distribution, cpu_cost, io_cost, temp_space, access_predicates, filter_predicates ) values(:1,SYSDATE,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,:16,:17,:18,:19,:20,:21,:22,:23,:24,:25,:26,:27)
=====================cpu_cost, io_cost, temp_space, access_predicates, filter_predicates seem to be invalid
Message was edited by:
smitjb -
Hi,
When I take an Explain Plan using TKPROF it gives the following error:
Error in CREATE TABLE of EXPLAIN PLAN table: APPS.prof$plan_table
ORA-00955: name is already used by an existing object
parse error offset: 18
EXPLAIN PLAN option disabled.
And the Explain Plan is snot displayed in the o/p file for all the queries.
Can any one help me on this.
Thanks,
KiranHi kiran
When I take an Explain Plan using TKPROF it gives the following error:
Error in CREATE TABLE of EXPLAIN PLAN table: APPS.prof$plan_table
ORA-00955: name is already used by an existing object
parse error offset: 18
EXPLAIN PLAN option disabled.
********************************************************************************What is your Db verssion and EBS? What is your kprof syntax. By the way please check those doc adn see its helpful:
Run Adadmin To Recreate Grants And Synonyms ORA-20000 ORA-00955 In Synonyms Loop:create_synonym(GL,PLAN_TABLE,APPS,PLAN_TABLE) [ID 437714.1]
TKPROF With Explain Fails With ORA-00903 invalid table name [ID 257294.1]
OERR: ORA 955 is already used by an existing object [ID 18549.1]
Also check:
Re: TKPROF and Explain Plan
Regard
Helios -
Hi,
I have created the plan_table using utlxplan.sql but still i am getting the error:
ORA-02404: specified plan table not found
Is there something else to be done to get it fixed?
please suggest.
Regards
ArpitAs Lukasz suggested check the table privs between the schema where the table was created and the user trying to use it. Also make sure there's a synonym for the user using explain plan to get to the plan table easily; a public synonym might work best
Maybe you are looking for
-
Dear Friends, In Message interface there is a option to select synchronous or asynchronous. If we select synchronous the fault message appearing and if select assynchronous the fault message disappearing, then in this case how can we do fault h
-
Formatting WD MyBook 1 Terabyte External Hard Drives
I recently purchased two WD MyBook Personal Edition 1 TB hard drives. These come formatted as MS-DOS FAT32, which is pretty useless for a Mac-only system. They are connected to my Mac Pro via a FW400 daisy chain. When I went to format these drives wi
-
Prevent ldap crawling for e-mail addresses
Hello, does anybody know can we prevent e-mail crawling from an ldap server. Thanks
-
Can i download and play lineage 2 on my macbook pro?
I know many people who have played on their macs when they needed to (not their first preference, but when nothing else is available...) and i was just wondering if/how it's possible to do that? I can't seem to get it to work.
-
Boot times/issu​es for Motorola vs. Cisco DVRs
We have a solar powered home, and I'd like to keep our DVR off during the night when we're not recording anything to save power. Is there any difference in the boot time or issues around repeated booting between the Cisco Chs435hdc, and Motorola