Showing posts with label TOAD. Show all posts
Showing posts with label TOAD. Show all posts

Tuesday, May 26, 2009

''IN' is not a valid integer value'" Bug In TOAD With Oracle 10.2

TOAD has a bug with its versions earlier than 8.6. You can check details of bug in TOAD's support. The resolution is to upgrade TOAD with new releases.
Follow the steps given below to fix it.

1) log in as SYS.
2) Get the script for ALL_ARGUMENTS view and create a new view called ALL_ARGUMENTS_OLD for backup.
3) Run the below script:

CREATE OR REPLACE VIEW all_arguments (owner,
object_name,
package_name,
object_id,
overload,
argument_name,
POSITION,
SEQUENCE,
data_level,
data_type,
DEFAULT_VALUE,
default_length,
in_out,
data_length,
data_precision,
data_scale,
radix,
character_set_name,
type_owner,
type_name,
type_subname,
type_link,
pls_type,
char_length,
char_used,
subprogram_id
)
AS
SELECT u.NAME, /* OWNER */
NVL (a.procedure$, o.NAME), /* OBJECT_NAME */
DECODE (a.procedure$, NULL, NULL, o.NAME), /* PACKAGE_NAME */
o.obj#, /* OBJECT_ID */
DECODE (a.overload#, 0, NULL, a.overload#), /* OVERLOAD */
a.argument,
/* ARGUMENT_NAME */
a.position#,
/* POSITION */
a.sequence#, /* SEQUENCE */
a.level#, /* DATA_LEVEL */
DECODE (a.type#, /* DATA_TYPE */
0, NULL,
1, DECODE (a.CHARSETFORM, 2, 'NVARCHAR2', 'VARCHAR2'),
2, DECODE (a.scale, -127, 'FLOAT', 'NUMBER'),
3, 'NATIVE INTEGER',
8, 'LONG',
9, DECODE (a.CHARSETFORM, 2, 'NCHAR VARYING', 'VARCHAR'),
11, 'ROWID',
12, 'DATE',
23, 'RAW',
24, 'LONG RAW',
29, 'BINARY_INTEGER',
69, 'ROWID',
96, DECODE (a.CHARSETFORM, 2, 'NCHAR', 'CHAR'),
100, 'BINARY_FLOAT',
101, 'BINARY_DOUBLE',
102, 'REF CURSOR',
104, 'UROWID',
105, 'MLSLABEL',
106, 'MLSLABEL',
110, 'REF',
111, 'REF',
112, DECODE (a.CHARSETFORM, 2, 'NCLOB', 'CLOB'),
113, 'BLOB',
114, 'BFILE',
115, 'CFILE',
121, 'OBJECT',
122, 'TABLE',
123, 'VARRAY',
178, 'TIME',
179, 'TIME WITH TIME ZONE',
180, 'TIMESTAMP',
181, 'TIMESTAMP WITH TIME ZONE',
231, 'TIMESTAMP WITH LOCAL TIME ZONE',
182, 'INTERVAL YEAR TO MONTH',
183, 'INTERVAL DAY TO SECOND',
250, 'PL/SQL RECORD',
251, 'PL/SQL TABLE',
252, 'PL/SQL BOOLEAN',
'UNDEFINED'
),
default$, /* DEFAULT_VALUE */
deflength, /* DEFAULT_LENGTH */
DECODE (in_out, NULL, 'IN', 1, 'OUT', 2, 'IN/OUT', 'Undefined'),
/* IN_OUT */
LENGTH, /* DATA_LENGTH */
precision#, /* DATA_PRECISION */
DECODE (a.type#, 2, scale, 1, NULL, 96, NULL, scale),
/* DATA_SCALE */
radix,
/* RADIX */
DECODE (a.CHARSETFORM,
1, 'CHAR_CS', /* CHARACTER_SET_NAME */
2, 'NCHAR_CS',
3, NLS_CHARSET_NAME (a.CHARSETID),
4, 'ARG:' || a.CHARSETID
),
a.type_owner, /* TYPE_OWNER */
a.type_name, /* TYPE_NAME */
a.type_subname, /* TYPE_SUBNAME */
a.type_linkname,
/* TYPE_LINK */
a.pls_type,
/* PLS_TYPE */
DECODE (a.type#, 1, a.scale, 96, a.scale, 0), /* CHAR_LENGTH */
DECODE (a.type#,
1, DECODE (BITAND (a.properties, 128), 128, 'C', 'B'),
96, DECODE (BITAND (a.properties, 128), 128, 'C', 'B'),
0
), /* CHAR_USED */
a.procedure# /* SUBPROGRAM ID */
FROM obj$ o, argument$ a, user$ u
WHERE o.obj# = a.obj#
AND o.owner# = u.user#
AND ( owner# = USERENV ('SCHEMAID')
OR EXISTS (SELECT NULL
FROM v$enabledprivs
WHERE priv_number IN (-144, -141))
OR o.obj# IN (
SELECT obj#
FROM SYS.objauth$
WHERE grantee# IN (SELECT kzsrorol
FROM x$kzsro)
AND privilege# = 12)
)
/


4) Now the error will be rectified. If you face the error again please restore the previous view which we made a backup in step 2.

Tuesday, November 4, 2008

Plan Table

Plan Table is a table which will be created to see the execution method of a SQL script. Using the execution method we can optimize the query. This is mostly used during performance tunning.

EXPLAIN PLAN is the utility used by oracle to know the execution path of the SQL query before actually executing it.

There are many third party to tool to know the performance of the query and the execution plan.
TOAD is one of such tool

Let us see how to view the explain plan in TOAD which is used while performance tunning

1. We should create a plan table to view the explain plan of the query
The script for creating a plan table will be in the following path
$ORACLE_HOME/rdbms/admin/ and the file name is utlxplan.sql
This script is used to create the plan table ( PLAN_TABLE)

2. Change the setting in your TOAD
Open the TOAD and go to View -> Options


Then go to Oracle -> General



In that give the schema and plan table name.
Schema : APPS
Table Name : PLAN_TABLE

3 .To view the explain plan
Create a query and click the explain plan tab in TOAD. Now you can see the execution method of the table which is used to optimize and tune the query


Errors while viewing Explain Plan
We may get two types of errors while viewing explain plan
1. ORA-02404: specified plan table not found
To resolve this error create the PLAN_TABLE in APPS schema

2.ORA-00904: "PARTITION_STOP": invalid identifier.
This indicates that the plan table was not properly created properly. To create the plan table execute the following query from the specified path
$ORACLE_HOME/rdbms/admin/utlxplan.sql

Use this code to create PLAN_TABLE if nothing works



CREATE TABLE PLAN_TABLE
(
STATEMENT_ID VARCHAR2(30 BYTE),
PLAN_ID NUMBER,
TIMESTAMP DATE,
REMARKS VARCHAR2(4000 BYTE),
OPERATION VARCHAR2(30 BYTE),
OPTIONS VARCHAR2(255 BYTE),
OBJECT_NODE VARCHAR2(128 BYTE),
OBJECT_OWNER VARCHAR2(30 BYTE),
OBJECT_NAME VARCHAR2(30 BYTE),
OBJECT_ALIAS VARCHAR2(65 BYTE),
OBJECT_INSTANCE INTEGER,
OBJECT_TYPE VARCHAR2(30 BYTE),
OPTIMIZER VARCHAR2(255 BYTE),
SEARCH_COLUMNS NUMBER,
ID INTEGER,
PARENT_ID INTEGER,
DEPTH INTEGER,
POSITION INTEGER,
COST INTEGER,
CARDINALITY INTEGER,
BYTES INTEGER,
OTHER_TAG VARCHAR2(255 BYTE),
PARTITION_START VARCHAR2(255 BYTE),
PARTITION_STOP VARCHAR2(255 BYTE),
PARTITION_ID INTEGER,
OTHER LONG,
DISTRIBUTION VARCHAR2(30 BYTE),
CPU_COST INTEGER,
IO_COST INTEGER,
TEMP_SPACE INTEGER,
ACCESS_PREDICATES VARCHAR2(4000 BYTE),
FILTER_PREDICATES VARCHAR2(4000 BYTE),
PROJECTION VARCHAR2(4000 BYTE),
TIME INTEGER,
QBLOCK_NAME VARCHAR2(30 BYTE),
OTHER_XML CLOB
)