Home » SQL & PL/SQL » SQL & PL/SQL » SP2-0552: Bind variable "5" not declared. (Oracle 11.2.0.3 , Linux)
SP2-0552: Bind variable "5" not declared. [message #621996] Wed, 20 August 2014 06:02 Go to next message
Srijesh
Messages: 24
Registered: August 2014
Location: Berlin
Junior Member
Hi,

User complained that after running the below sql query for a while they are getting exception error like user cancelled request.
This query is run from a java batch program.They also mentioned that they are facing problem only when this query run from
java batch program.Earlier they got the output from sqlplus but when they run teh same query nowin sqlplus it is taking more time.

When i run the same query in sqlplus,i get SP2-0552: error
SQL> Select h.execution_id as executionId, h.calib_ref_key as calibRefKey, count(*) as noOfSamples, avg(r.test_result) as average, stddev(r.test_result) as stdDev, 9.0 as upperSpecLimit, -6.0 as lowSpecLimit, 1.5 as targetResult from dat_rtqm_test_header h inner join ( (select * from dat_rtqm_test_result4) ) r on h.testdata_ref_key = r.testdata_ref_key where DATE_TIME >= :1 and DATE_TIME < :2 and h.station_id = :3 and r.test_step_id = :4 and r.test_step_rev = :5 and ( ( calib_ref_key = 8376 and date_time > :6 ) or ( calib_ref_key = 6545 and date_time > :7 ) ) group by h.execution_id, h.calib_ref_key
  2  /
SP2-0552: Bind variable "5" not declared.
SQL>


Below is the explain plan for sql query.

SQL> explain plan for Select h.execution_id as executionId, h.calib_ref_key as calibRefKey, count(*) as noOfSamples, avg(r.test_result) as average, stddev(r.test_result) as stdDev, 9.0 as upperSpecLimit, -6.0 as lowSpecLimit, 1.5 as targetResult from dat_rtqm_test_header h inner join ( (select * from dat_rtqm_test_result4) ) r on h.testdata_ref_key = r.testdata_ref_key where DATE_TIME >= :1 and DATE_TIME < :2 and h.station_id = :3 and r.test_step_id = :4 and r.test_step_rev = :5 and ( ( calib_ref_key = 8376 and date_time > :6 ) or ( calib_ref_key = 6545 and date_time > :7 ) ) group by h.execution_id, h.calib_ref_key
  2  /

Explained.

SQL> SELECT * FROM table(dbms_xplan.display);

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------
| Id  | Operation                             | Name                    | Rows  | Bytes | Cost (%CPU)|
------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                      |                         |     1 |    50 |   420   (3)|
|   1 |  HASH GROUP BY                        |                         |     1 |    50 |   420   (3)|
|*  2 |   FILTER                              |                         |       |       |            |
|   3 |    NESTED LOOPS                       |                         |       |       |            |
|   4 |     NESTED LOOPS                      |                         |     1 |    50 |   419   (3)|
|*  5 |      TABLE ACCESS BY INDEX ROWID      | DAT_RTQM_TEST_HEADER    |     1 |    32 |   416   (3)|
|   6 |       BITMAP CONVERSION TO ROWIDS     |                         |       |       |            |

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|   7 |        BITMAP AND                     |                         |       |       |            |
|   8 |         BITMAP CONVERSION FROM ROWIDS |                         |       |       |            |
|   9 |          SORT ORDER BY                |                         |       |       |            |
|* 10 |           INDEX RANGE SCAN            | DAT_RTQM_TEST_HEADER_I2 |  3643 |       |    61   (0)|
|  11 |         BITMAP OR                     |                         |       |       |            |
|  12 |          BITMAP CONVERSION FROM ROWIDS|                         |       |       |            |
|  13 |           SORT ORDER BY               |                         |       |       |            |
|* 14 |            INDEX RANGE SCAN           | DAT_RTQM_TEST_HEADER_I2 |  3643 |       |   119   (0)|
|  15 |          BITMAP CONVERSION FROM ROWIDS|                         |       |       |            |
|  16 |           SORT ORDER BY               |                         |       |       |            |
|* 17 |            INDEX RANGE SCAN           | DAT_RTQM_TEST_HEADER_I2 |  3643 |       |   119   (0)|

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|* 18 |      INDEX RANGE SCAN                 | DAT_RTQM_TEST_RESULT4_I |     1 |       |     2   (0)|
|* 19 |     TABLE ACCESS BY INDEX ROWID       | DAT_RTQM_TEST_RESULT4   |     1 |    18 |     3   (0)|
------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter(TO_DATE(:1)<TO_DATE(:2))
   5 - filter("H"."STATION_ID"=:3 AND ("H"."CALIB_REF_KEY"=8376 AND "H"."DATE_TIME">:6 OR
              "H"."CALIB_REF_KEY"=6545 AND "H"."DATE_TIME">:7))
  10 - access("H"."DATE_TIME">=:1 AND "H"."DATE_TIME"<:2)

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  14 - access("H"."DATE_TIME">:6)
       filter("H"."DATE_TIME">:6)
  17 - access("H"."DATE_TIME">:7)
       filter("H"."DATE_TIME">:7)
  18 - access("H"."TESTDATA_REF_KEY"="DAT_RTQM_TEST_RESULT4"."TESTDATA_REF_KEY" AND
              "DAT_RTQM_TEST_RESULT4"."TEST_STEP_ID"=TO_NUMBER(:4))
  19 - filter("DAT_RTQM_TEST_RESULT4"."TEST_STEP_REV"=TO_NUMBER(:5))

Note
-----
   - 'PLAN_TABLE' is old version

44 rows selected.


Please suggest me how to fix this SP2 error and make query run faster.

Note: --The objects involved in the query belongs to DEMO user and i have pulled the explain plan of it by logging as DEMO user.

Regards,
Srijesh

[Updated on: Wed, 20 August 2014 06:42]

Report message to a moderator

Re: SP2-0552: Bind variable "5" not declared. [message #622002 is a reply to message #621996] Wed, 20 August 2014 06:56 Go to previous messageGo to next message
Srijesh
Messages: 24
Registered: August 2014
Location: Berlin
Junior Member
I ran the same query in sqlplus and it return no rows in 2 minutes.
SQL> select h.execution_id as executionId,
       h.calib_ref_key as calibRefKey,
       count(*) as noOfSamples,
  2    3    4         avg(r.test_result) as average,
  5         stddev(r.test_result) as stdDev,
  6         20 as upperSpecLimit,
       10 as lowSpecLimit,
       15 as targetResult
  7    8    9    from dat_rtqm_test_header h
 10  inner join (select * from dat_rtqm_test_result3) r
 11      on h.testdata_ref_key = r.testdata_ref_key
 12  where DATE_TIME >= TO_DATE('2014-07-10 14:00:00', 'yyyy-mm-dd hh24:mi:ss')
   and DATE_TIME < TO_DATE('2014-07-10 14:30:00', 'yyyy-mm-dd hh24:mi:ss')
 13   14     and h.station_id = '6A_440PEA01'
 15     and r.test_step_id = 3815
   and r.test_step_rev = 1
 16   17     and((calib_ref_key='10650' and date_time > TO_DATE('2014-07-10 14:19:39','yyyy-mm-dd hh24:mi:ss') or (calib_ref_key = '13699' and date_time > TO_DATE('2014-07-10 14:19:30', 'yyyy-mm-dd hh24:mi:ss')))) group by h.execution_id, h.calib_ref_key;

no rows selected

Elapsed: 00:02:37.12


I ran the same query after sometime and it got completed within 1 minute.
SQL> select h.execution_id as executionId,
       h.calib_ref_key as calibRefKey,
       count(*) as noOfSamples,
  2    3    4         avg(r.test_result) as average,
  5         stddev(r.test_result) as stdDev,
  6         20 as upperSpecLimit,
  7         10 as lowSpecLimit,
  8         15 as targetResult
  9    from dat_rtqm_test_header h
 10  inner join (select * from dat_rtqm_test_result3) r
 11      on h.testdata_ref_key = r.testdata_ref_key
where DATE_TIME >= TO_DATE('2014-07-10 14:00:00', 'yyyy-mm-dd hh24:mi:ss')
 12   13     and DATE_TIME < TO_DATE('2014-07-10 14:30:00', 'yyyy-mm-dd hh24:mi:ss')
 14     and h.station_id = '6A_440PEA01'
 15     and r.test_step_id = 3815
 16     and r.test_step_rev = 1
 17     and((calib_ref_key='10650' and date_time > TO_DATE('2014-07-10 14:19:39','yyyy-mm-dd hh24:mi:ss') or (calib_ref_key = '13699' and date_time > TO_DATE('2014-07-10 14:19:30', 'yyyy-mm-dd hh24:mi:ss')))) group by h.execution_id, h.calib_ref_key;

no rows selected

Elapsed: 00:01:36.95


Here is the Trace of the problem SQL when it is running.
TKPROF: Release 11.2.0.3.0 - Development on Wed Aug 20 19:08:40 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Trace file: ORA_ora_20830.trc
Sort options: default

********************************************************************************
count    = number of times OCI procedure was executed
cpu      = cpu time in seconds executing 
elapsed  = elapsed time in seconds executing
disk     = number of physical reads of buffers from disk
query    = number of buffers gotten for consistent read
current  = number of buffers gotten in current mode (usually for update)
rows     = number of rows processed by the fetch or execute call
********************************************************************************

SQL ID: 4kvc1pjyh5n7x Plan Hash: 0

ALTER SESSION SET SQL_TRACE=TRUE


call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        0      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        1      0.00       0.00          0          0          0           0

Misses in library cache during parse: 0
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS
********************************************************************************

SQL ID: dbmdavb6ydwb4 Plan Hash: 0

ALTER SESSION SET SQL_TRACE=FALSE


call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.00       0.00          0          0          0           0

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS



********************************************************************************

OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      2      0.00       0.00          0          0          0           0
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        3      0.00       0.00          0          0          0           0

Misses in library cache during parse: 1
Misses in library cache during execute: 1


OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        0      0.00       0.00          0          0          0           0
Execute      0      0.00       0.00          0          0          0           0
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        0      0.00       0.00          0          0          0           0

Misses in library cache during parse: 0

    2  user  SQL statements in session.
    0  internal SQL statements in session.
    2  SQL statements in session.
********************************************************************************
Trace file: HVMES1_ora_20830.trc
Trace file compatibility: 11.1.0.7
Sort options: default

       1  session in tracefile.
       2  user  SQL statements in trace file.
       0  internal SQL statements in trace file.
       2  SQL statements in trace file.
       2  unique SQL statements in trace file.
      37  lines in trace file.
     162  elapsed seconds in trace file.


[Updated on: Wed, 20 August 2014 07:18]

Report message to a moderator

Re: SP2-0552: Bind variable "5" not declared. [message #622011 is a reply to message #621996] Wed, 20 August 2014 07:46 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
When i run the same query in sqlplus,i get SP2-0552: error


Balaji/Ajit/Jack/Mohan/Mathew/Suhas/Srini/william/Srikanth/david/Srijesh Fraudy Dumby,

Read SQL*Plus documentation and you know why (if you can read).
8 years as a DBA and you don't even know that.

Quote:
make query run faster.


Read the performances sticky and post the requested information (if you can read).
And FORMAT your queries as required (if you can read).
Re: SP2-0552: Bind variable "5" not declared. [message #622015 is a reply to message #622011] Wed, 20 August 2014 08:30 Go to previous messageGo to next message
Srijesh
Messages: 24
Registered: August 2014
Location: Berlin
Junior Member
Quote:
Read the performances sticky and post the requested information (if you can read).
And FORMAT your queries as required (if you can read).


I have provided enough of information.Answer me if you can.
I hope queries are formatted.
Re: SP2-0552: Bind variable "5" not declared. [message #622017 is a reply to message #622015] Wed, 20 August 2014 08:36 Go to previous messageGo to next message
John Watson
Messages: 8929
Registered: January 2010
Location: Global Village
Senior Member
Srijesh wrote on Wed, 20 August 2014 14:30
Quote:
Read the performances sticky and post the requested information (if you can read).
And FORMAT your queries as required (if you can read).


I have provided enough of information.Answer me if you can.
I hope queries are formatted.
You have not provided enough information.
Look at your trace file: it has two commands, neither of which is the statement.
Your queries are not formatted. If you don't know how to do it, try this,
http://www.dpriver.com/pp/sqlformat.htm

Re: SP2-0552: Bind variable "5" not declared. [message #622018 is a reply to message #622015] Wed, 20 August 2014 08:40 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Srijesh wrote on Wed, 20 August 2014 14:30
Quote:
Read the performances sticky and post the requested information (if you can read).
And FORMAT your queries as required (if you can read).

I have provided enough of information.Answer me if you can.

No you really haven't. Read the trace file you posted above, do you think it contains anything useful?
Plus we really do expect you to provide the other information detailed in the performance tuning sticky and I'm sure we've pointed it out to you before.

Srijesh wrote on Wed, 20 August 2014 14:30

I hope queries are formatted.

Don't hope, know. The first ones aren't formatted at all, the later ones are beter but the SQLplus line numbers have messed it up.
Re: SP2-0552: Bind variable "5" not declared. [message #622021 is a reply to message #622018] Wed, 20 August 2014 09:06 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>Trace file compatibility: 11.1.0.7
Why?


> 162 elapsed seconds in trace file.
but posted content does not show any where that amount of elapsed time. Why?
Re: SP2-0552: Bind variable "5" not declared. [message #622023 is a reply to message #622021] Wed, 20 August 2014 09:13 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
elapsed sections is just how long trace was on for
Re: SP2-0552: Bind variable "5" not declared. [message #622026 is a reply to message #622018] Wed, 20 August 2014 09:33 Go to previous messageGo to next message
Srijesh
Messages: 24
Registered: August 2014
Location: Berlin
Junior Member
Here is the query with actual value.
SQL> SELECT h.execution_id        AS executionId,
       h.calib_ref_key       AS calibRefKey,
       Count(*)              AS noOfSamples,
  2    3    4         Avg(r.test_result)    AS average,
  5         Stddev(r.test_result) AS stdDev,
  6         20                    AS upperSpecLimit,
  7         10                    AS lowSpecLimit,
  8         15                    AS targetResult
  9  FROM   dat_rtqm_test_header h
 10         INNER JOIN (SELECT *
 11                     FROM   dat_rtqm_test_result3) r
 12                 ON h.testdata_ref_key = r.testdata_ref_key
 13  WHERE  date_time >= To_date('2014-07-10 14:00:00', 'yyyy-mm-dd hh24:mi:ss')
 14         AND date_time < To_date('2014-07-10 14:30:00', 'yyyy-mm-dd hh24:mi:ss')
 15         AND h.station_id = '6A_440PEA01'
 16         AND r.test_step_id = 3815
       AND r.test_step_rev = 1
 17   18         AND (( calib_ref_key = '10650'
              AND date_time > To_date('2014-07-10 14:19:39',
 19   20                                'yyyy-mm-dd hh24:mi:ss')
 21                 OR ( calib_ref_key = '13699'
 22                      AND date_time > To_date('2014-07-10 14:19:30',
 23                                      'yyyy-mm-dd hh24:mi:ss')
 24                    ) ))
 25  GROUP  BY h.execution_id,
 26            h.calib_ref_key;

no rows selected

SQL>


Here is the Trace of the problem SQL when it is running.
TKPROF: Release 11.2.0.3.0 - Development on Wed Aug 20 21:29:11 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Trace file: ORCL_ora_1080.trc
Sort options: default

********************************************************************************
count    = number of times OCI procedure was executed
cpu      = cpu time in seconds executing 
elapsed  = elapsed time in seconds executing
disk     = number of physical reads of buffers from disk
query    = number of buffers gotten for consistent read
current  = number of buffers gotten in current mode (usually for update)
rows     = number of rows processed by the fetch or execute call
********************************************************************************
Trace file: ORCL_ora_1080.trc
Trace file compatibility: 11.1.0.7
Sort options: default

       1  session in tracefile.
       0  user  SQL statements in trace file.
       0  internal SQL statements in trace file.
       0  SQL statements in trace file.
       0  unique SQL statements in trace file.
      24  lines in trace file.
       0  elapsed seconds in trace file.


Please let me know what else information you need.

[Updated on: Wed, 20 August 2014 09:35]

Report message to a moderator

Re: SP2-0552: Bind variable "5" not declared. [message #622027 is a reply to message #622026] Wed, 20 August 2014 09:46 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Ok serious suggestion - find yourself a less taxing job, you spend so little effort thinking about what you do that you're not even bad at it.
Both myself and John have pointed out that the previous trace file contains nothing useful.
The new trace file contains even less information than the first one, partly because you had it running for less than a second (I say partly since the one ran a lot longer and still didn't capture anything)

We have also asked you to read the performance tunning sticky and post the information requested. If you don't know where that is ASK, don't just ignore it because you can't be bothered to work out what we mean.
Re: SP2-0552: Bind variable "5" not declared. [message #622030 is a reply to message #622027] Wed, 20 August 2014 10:02 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
To moderators, et al.

The advice to ignore rather than engage with a troll is sometimes phrased as "Please do not feed the trolls."
Re: SP2-0552: Bind variable "5" not declared. [message #622031 is a reply to message #622030] Wed, 20 August 2014 10:07 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Here's not a troll he is just stupid.

Re: SP2-0552: Bind variable "5" not declared. [message #622036 is a reply to message #622031] Wed, 20 August 2014 10:27 Go to previous messageGo to next message
Srijesh
Messages: 24
Registered: August 2014
Location: Berlin
Junior Member
and you 're a idiot
Re: SP2-0552: Bind variable "5" not declared. [message #622038 is a reply to message #622031] Wed, 20 August 2014 10:37 Go to previous messageGo to next message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
Michel Cadot wrote on Wed, 20 August 2014 10:07

Here's not a troll he is just stupid.



Either way, he/she stills seems to draw nourishment from the negative comments. So the same DNFTT still applies.
Re: SP2-0552: Bind variable "5" not declared. [message #622042 is a reply to message #622038] Wed, 20 August 2014 11:05 Go to previous messageGo to next message
Srijesh
Messages: 24
Registered: August 2014
Location: Berlin
Junior Member
Stevens

Dont you think Michel is not answering my question properly and using ribbish words always.Thats y i used those words
Re: SP2-0552: Bind variable "5" not declared. [message #622043 is a reply to message #622042] Wed, 20 August 2014 11:16 Go to previous messageGo to next message
Srijesh
Messages: 24
Registered: August 2014
Location: Berlin
Junior Member
Its all because of him i am creating several accounts.He keeps disturbing me.
Re: SP2-0552: Bind variable "5" not declared. [message #622053 is a reply to message #622043] Wed, 20 August 2014 11:50 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
Srijesh wrote on Wed, 20 August 2014 21:46
Its all because of him i am creating several accounts.He keeps disturbing me.


How is it possible that "he" is disturbing "you"? Please be sane.
Re: SP2-0552: Bind variable "5" not declared. [message #622088 is a reply to message #622053] Wed, 20 August 2014 23:43 Go to previous messageGo to next message
Srijesh
Messages: 24
Registered: August 2014
Location: Berlin
Junior Member
Read my previous threads you will know who is troubling whom?
Re: SP2-0552: Bind variable "5" not declared. [message #622089 is a reply to message #622088] Wed, 20 August 2014 23:53 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Question is not who, but why?
Re: SP2-0552: Bind variable "5" not declared. [message #622093 is a reply to message #622089] Thu, 21 August 2014 00:56 Go to previous message
Srijesh
Messages: 24
Registered: August 2014
Location: Berlin
Junior Member
<Question is not who, but why?>

what do you mean by why ?
Previous Topic: Row Count as End of the Row
Next Topic: query
Goto Forum:
  


Current Time: Fri Apr 19 22:24:30 CDT 2024