SQL statement is not performing

Hi community,
I've a problem with a SQL statement.
First of all here's the statement and the explain plan for it:
select PPRJPOI.BBASE , PPRJPOI.CONTROLLINGAREA, PPRJPOI.COSTOBJTYPE , PPRJPOI.COSTOBJMAINPATH , PPRJPOI.COSTOBJSUBPATH ,
PPRJPOI.PPOSNUM , PPRJPOI.PPOSTXT , PPRJPOI.PPOSBTG , PPRJPOI.PDCWABL , PPRJPOI.PDCWNUM , PPRJPOI.PDCWBUD , PPRJPOI.PKTOORI ,
PPRJPOI.REFKEY1 , PPRJ.COSTCENTER , PPRJ.PATHELEM1 , PPRJSUB.PTPRTXT , LSUPPLIER.AADDRLINE1
from PPRJPOI
inner join PPRJ on PPRJ.BBASE = PPRJPOI.BBASE and PPRJ.CONTROLLINGAREA = PPRJPOI.CONTROLLINGAREA
and PPRJ.COSTOBJTYPE = PPRJPOI.COSTOBJTYPE and PPRJ.COSTOBJMAINPATH = PPRJPOI.COSTOBJMAINPATH
and PPRJ.COORGPATHELEM1 = ? and PPRJ.COORGPATHELEM2 = ? and PPRJ.COORGPATHELEM3 = ?
and PPRJ.COORGPATHELEM4 = ? and PPRJ.COORGPATHELEM5 = ?
inner join PPRJSUB on PPRJSUB.BBASE = PPRJPOI.BBASE and PPRJSUB.CONTROLLINGAREA = PPRJPOI.CONTROLLINGAREA
and PPRJSUB.COSTOBJTYPE = PPRJPOI.COSTOBJTYPE and PPRJSUB.COSTOBJMAINPATH = PPRJPOI.COSTOBJMAINPATH
and PPRJSUB.COSTOBJSUBPATH = PPRJPOI.COSTOBJSUBPATH
left outer join LSUPPLIER on LSUPPLIER.BBASE = PPRJPOI.BBASE and LSUPPLIER.LSUPPLIERNUM = PPRJPOI.PLFTNUM
where PPRJPOI.BBASE = ? and PPRJPOI.CONTROLLINGAREA = ? and PPRJPOI.COSTOBJTYPE = ?
and PPRJPOI.SUMSTS = ? and (PPRJPOI.MOVCOSTOBJMAINPATH is null or PPRJPOI.CLEAREDITEM = ?)
and (PPRJPOI.CLEAREDITEM ? or PPRJPOI.CLEAREDITEM is null)
and PPRJPOI.COYEARID = ? and (PPRJPOI.COPERIODNUM between ? and ? )
and PPRJPOI.BTS_CREATE <= TO_TIMESTAMP('27.10.2008 17:00:00')
and PPRJPOI.PATHELEM2 = ? and PPRJPOI.PATHELEM3 = ?
order by PPRJPOI.BBASE, PPRJPOI.CONTROLLINGAREA, PPRJPOI.COSTOBJTYPE,
PPRJPOI.COSTOBJMAINPATH, PPRJPOI.COSTOBJSUBPATH
| Id  | Operation                        | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT                 |              |     1 |   489 |    40   (5)| 00:00:01 |
|   1 |  SORT ORDER BY                   |              |     1 |   489 |    40   (5)| 00:00:01 |
|*  2 |   FILTER                         |              |       |       |            |          |
|   3 |    NESTED LOOPS OUTER            |              |     1 |   489 |    39   (3)| 00:00:01 |
|   4 |     NESTED LOOPS                 |              |     1 |   439 |    38   (3)| 00:00:01 |
|*  5 |      HASH JOIN                   |              |     1 |   262 |    37   (3)| 00:00:01 |
|   6 |       TABLE ACCESS BY INDEX ROWID| PPRJ         |     1 |    95 |     1   (0)| 00:00:01 |
|*  7 |        INDEX RANGE SCAN          | PPRJ_ORA4    |     1 |       |     1   (0)| 00:00:01 |
|*  8 |       TABLE ACCESS BY INDEX ROWID| PPRJPOI      |    41 |  6847 |    36   (3)| 00:00:01 |
|*  9 |        INDEX SKIP SCAN           | PPRJPOI_ORA3 |    83 |       |    26   (0)| 00:00:01 |
|  10 |      TABLE ACCESS BY INDEX ROWID | PPRJSUB      |     1 |   177 |     1   (0)| 00:00:01 |
|* 11 |       INDEX UNIQUE SCAN          | PK_233       |     1 |       |     1   (0)| 00:00:01 |
|  12 |     TABLE ACCESS BY INDEX ROWID  | LSUPPLIER    |     1 |    50 |     1   (0)| 00:00:01 |
|* 13 |      INDEX UNIQUE SCAN           | PK_177597    |     1 |       |     1   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   2 - filter(:13<=:14)
   5 - access("PPRJ"."BBASE"="PPRJPOI"."BBASE" AND
              "PPRJ"."CONTROLLINGAREA"="PPRJPOI"."CONTROLLINGAREA" AND
              "PPRJ"."COSTOBJTYPE"="PPRJPOI"."COSTOBJTYPE" AND
              "PPRJ"."COSTOBJMAINPATH"="PPRJPOI"."COSTOBJMAINPATH")
   7 - access("PPRJ"."BBASE"=:6 AND "PPRJ"."CONTROLLINGAREA"=:7 AND
              "PPRJ"."COSTOBJTYPE"=:8 AND "PPRJ"."COORGPATHELEM1"=:1 AND "PPRJ"."COORGPATHELEM2"=:2
              AND "PPRJ"."COORGPATHELEM3"=:3 AND "PPRJ"."COORGPATHELEM4"=:4 AND
              "PPRJ"."COORGPATHELEM5"=:5)
   8 - filter("PPRJPOI"."SUMSTS"=:9 AND ("PPRJPOI"."MOVCOSTOBJMAINPATH" IS NULL OR
              "PPRJPOI"."CLEAREDITEM"=:10) AND ("PPRJPOI"."CLEAREDITEM" IS NULL OR
              "PPRJPOI"."CLEAREDITEM"<>:11) AND "PPRJPOI"."BTS_CREATE"<=TO_TIMESTAMP('27.10.2008
              17:00:00'))
   9 - access("PPRJPOI"."BBASE"=:6 AND "PPRJPOI"."CONTROLLINGAREA"=:7 AND
              "PPRJPOI"."COSTOBJTYPE"=:8 AND "PPRJPOI"."COYEARID"=:12 AND "PPRJPOI"."COPERIODNUM">=:13
              AND "PPRJPOI"."PATHELEM2"=:15 AND "PPRJPOI"."PATHELEM3"=:16 AND
              "PPRJPOI"."COPERIODNUM"<=:14)
       filter("PPRJPOI"."PATHELEM3"=:16 AND "PPRJPOI"."PATHELEM2"=:15)
  11 - access("PPRJSUB"."BBASE"=:6 AND "PPRJSUB"."CONTROLLINGAREA"=:7 AND
              "PPRJSUB"."COSTOBJTYPE"=:8 AND "PPRJSUB"."COSTOBJMAINPATH"="PPRJPOI"."COSTOBJMAINPATH"
              AND "PPRJSUB"."COSTOBJSUBPATH"="PPRJPOI"."COSTOBJSUBPATH")
  13 - access("LSUPPLIER"."BBASE"(+)=:6 AND "LSUPPLIER"."LSUPPLIERNUM"(+)="PPRJPOI"."PLFT
              NUM")Additional infos:
Tablesize:
PPRJPOI - 44.500.000 rows
PPRJ - 7.013 rows
PPRJSUB - 1.150.000 rows
LSUPPLIER - 115.000 rows
Used indexes:
PPRJ_ORA4: index on PPRJ(BBASE, CONTROLLINGAREA, COSTOBJTYPE, COORGPATHELEM1, COORGPATHELEM2, COORGPATHELEM3 ,COORGPATHELEM4 , COORGPATHELEM5 , COORGPATHELEM6, COORGPATHELEM7, COORGPATHELEM8);
PPRJPOI_ORA3: index on PPRJPOI(BBASE, CONTROLLINGAREA, COSTOBJTYPE, COYEARID, COPERIODNUM, PATHELEM2, PATHELEM3, PATHELEM4, PATHELEM5, PATHELEM6, PATHELEM7, PATHELEM8);
PK_233: index on PPRJSUB(BBASE, CONTROLLINGAREA, COSTOBJTYPE, COSTOBJMAINPATH, COSTOBJSUBPATH);
PK_177597: index on LSUPPLIER(BBASE, LSUPPLIERNUM);
If I execute this statement I recieve a resultset which returns 5800 rows and takes about 70 seconds. Executing the same statement on DB2 returns the same number of rows but lasts only 15 seconds.
I would really appreciate, if anybody can help me optimizing this statement so that the execution time will be equal to the DB2..
Thanks in advance,
Tobias Schmidt
Edited by: tobiwan on Oct 31, 2008 1:01 PM

tobiwan wrote:
The statement we use is a prepared statement and the "?" are standing for the binding variables.
I generated the explain plan by adding the prefix "explain plan for" to the statement and fetching the result by executing the statement "SELECT * FROM TABLE(dbms_xplan.display)". The plan table was created with the Oracle script ($ORACLE_HOME\RDBMS\ADMIN\utlxplan.sql).The cardinality estimates of the plan posted seem to be way off if you say that the statement returns 5,800 records, but since you're using bind variables the optimizer in the case of an "EXPLAIN PLAN" just applies default selectivities, like 1% for an equal comparison 5% for a range comparison etc.
Note that you're using (a lot of) bind variables and therefore the output of EXPLAIN PLAN is only of limited help, because it doesn't/can't use the "bind variable peeking" that happens when the statement is actually executed.
So you need to find out the actual execution plan(s) used at run time. You can use the convenient DBMS_XPLAN.DISPLAY_CURSOR function in 10g to obtain that information. You just need to find out the SQL_ID of your statement if it is cached in the Shared Pool, e.g. by searching the V$SQL* views available, or you can check V$SESSION if you know that the statement is currently being executed.
You should check if you've histograms in place on the columns used with the bind variables, in a different thread I've provided already this useful blog note by the Pythian Group about this issue.
http://www.pythian.com/blogs/867/stabilize-oracle-10gs-bind-peeking-behaviour-by-cutting-histograms
Once you've obtained the actual execution plan(s, it could be multiple if you have histograms in place), post them here to find out if the cardinality estimates are still way off or what else could be the reason for the unexpected long execution time.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/

Similar Messages

  • The SQL statement is not valid - when importing data from SQL Server using a query

    Hi there,
    I am trying to import data from SQL to Power Pivot using a SQL query like below:
    SELECT Score.FieldCount, Score.Record.GetAt(0), Score.Record.GetAt(1),  Score.Record.GetAt(2),  Score.Record.GetAt(3),  Score.Record.GetAt(4)
    FROM 
    SELECT * FROM dbo.CLR1(
    dbo.CLR2('c:\FILES\Test.xml'), 
    'SELECT * FROM [dbo].[CXCustomer_Small]') Input
    ) Score
    And when I tried to validate it, it returns
    The SQL statement is not valid. A column name cannot be blank.
    I ran the above SQL statement in Management Studio and it works without problem. Any idea?
    Thanks!
    Chu
    -- Predict everything. http://www.predixionsoftware.com

    Never mind, I figured out - I need to give each column a name.
    -- Predict everything. http://www.predixionsoftware.com

  • Executing the SQL statement is not allowed - Error

    I am getting "Executing the SQL statement is not allowed" for an INSERT cfquery that I'm running.  I checked the usual suspects:
    - DSN allows INSERT
    - I've seen reports online where certain field names or values are considered key words, so for protection CF blocks the query in this way (it would be nice if there was a different error message when it gets blocked this way vs. the DSN doesn't allow INSERT error message).  The field names and values were all benign strings, so it didn't seem like that.
    I took the same string for the query and ran it on another page and it ran fine (same DSN, too).

    SOLVED: I decided to enter this in here, just to get it into web searches for others since I couldn't find anything.
    - I was calling a function for one of the values in the query:  get_db_status_code("initialize")  Apparently CF parses the query to see if it's allowed BEFORE it runs the CFML in it, so something in that function name, or the parameter "initialize" was a key word that CF doesn't allow.  I moved the function call outside of the query and loaded a temp variable for use in the query and it then worked.

  • SQL statement for calculating performance targets

    Hi
    I have taken of the admin of a database which stores project goals and scores. I have to develop a way to calculate how well all projects meet these scores. The table concerned is called goal and looks like this:
    goal
    goal_name
    project_code
    current_value
    good_value
    bad_value
    This can be for many different goals, for example if a project wants to get up a goal of having no more than 5 bugs in the project. I can also set a bad value, say 20, so if any projects have 20 or more bugs, triggers or alerts can be sent So I can enter into this table. The reason for putting 5 for good not 20 is because these scores are to be realistic.
    project_code = foo
    goal_name = software bugs
    good_value = 5
    bad_value = 20
    However, some goals may have the values switched and be in a much higher range, or may even be a percentage. For example one for number of sales could be
    project_code = foo
    goal_name = software sales
    good_value = 200
    bad_value = 50
    or project delay
    project_code = foo
    goal_name = sproject delay
    good_value = 0%
    bad_value = 50%
    i am trying to develop a SQL statement so I can get a % score of how well a goal is performing, so I can see
    What is the goal % for all foo goals
    Or what is the goal % for goal 'software sales'
    And also more importantly, how well are the goals doing globally.
    The requirement for doing this is using a single SQL statement, well, one SQL statement for the requirements I listed above, so for example the semantics are
    SELECT average(goal perforance) WHERE .... project = foo .... or goal = software sales... etc
    I am having trouble doing this, I have been banging my head against mydesk all day. the biggest thing is thowing me off is that the good value can be higher or lower than the bad value, and I am having trouble visualizing how to but this conditional statement in SQL
    One more thing, the percentage returned should never be more than 0% or 100%.
    If anyone has any ideas or pointers, please help me out,
    Thanks for your time,
    Message was edited by:
    user473327

    I am having trouble doing this, I have been banging
    my head against mydesk all day. the biggest thing is
    thowing me off is that the good value can be higher
    or lower than the bad value, and I am having trouble
    visualizing how to but this conditional statement in
    SQLI haven't looked at your requirements in detail cos I don't have time for such cumbersome tasks. However, you could have two UNION'd select statements, one which caters for the good > bad and one which caters for the good < bad. Also and alternative would be the use of DECODE or CASE statements in your select which are good for switching things around based on conditions.
    ;)

  • SQL statement length downgrades performance

    Hi all!!!
    I wonder if someone have noticed this or knows an answer on it. When the length of an SQL sentence is greater than 2000 bytes (+ or -) the time to process grows dramatically. See examples and environment below.
    No matter how complex the query is, the time to execute the 'executeQuery' can be x10 times slower than small queries. There is no need to send complicate queries. I have even test it using a simple 'SELECT SYSDATE FROM DUAL'. I'm unable to understand why the time to process this query can vary from 10ms to 130ms just by appending blank spaces into the query (i.e.: 'SELECT SYSDATE FROM DUAL ')
    Examples:
    The times shown are taken using 'System.currentTimeMillis()' just before and after the call to 'executeQuery()' or 'execute(sql):
    'SELECT SYSDATE FROM DUAL' -> takes from 0ms to 30ms
    'SELECT SYSDATE FROM DUAL' + 1000_blank_spaces (' ') -> takes from 0ms to 30ms (the same)
    'SELECT SYSDATE FROM DUAL' + 2000_blank_spaces (' ') -> takes from 100ms to 130ms
    I have made a loop increasing spaces 1 by 1 up to 2500. I found that the performance is always on the range 0-30ms up to a total length of 1970 characters. After that, all the queries takes 100-130ms.
    I also tested with very complex queries (implying several tables and indexes) like 'SELECT field_1, field_2 FROM table_1, table_2 WHERE very_complex_condition'. This may take 10-30ms. However, if something is added to that query (i.e a 'field_3' on the SELECT, blank spaces, a new 'AND', etc...) that makes the string be larger than 1970 characters, the query takes then 100-130ms.
    The same results are get using Statements or PreparedStatements.
    I end up that when the SQL String is close to 2Kb the JDBC Thin Driver spends 100ms doing something unknown. This seems to be an issue on the Thin driver, since the same tests using OCI give homogeneous time (no mater the length) but they are slower than the Thin driver (70-80ms for the same 'SELECT SYSDATE FROM DUAL'). It does not seems to be related with the network because some of the tests used the same machine (server and client).
    Does anyone have an explanation about this?. All suggestions are welcome.
    Here comes the technical info:
    SERVER
    - Oracle 8.1.6 on Solaris 8 sparc 64 bits (Sun ultra-10).
    CLIENTs
    - Windows NT 4 / Solaris 8 (tha same box as the server)
    - JDK 130 / JDK 131
    - JDBC 8.1.6 / JDBC 8.1.7 (downloaded from Oracle site)
    Best regards
    Roberto.

    More on this.
    After increasing the length of the SQL statement up to 3600 bytes and more, the execution time goes back to 10-30ms. So performance is only bad in the range 2Kb-3.5Kb
    I'm really confused about this issue.

  • TestStand Open SQL Statement does not support SQL's ORDER BY clause???

    TestStand 1.0.3
    Windows 2000 SP1
    SQL Server 2000 Personal
    You've got to be kidding me...
    It appears that the built-in TestStand Open SQL Step does NOT support the
    "ORDER BY" clause in the SELECT statement, even though the documentation
    says it does. Is this true?
    I have an Open SQL Statement query:
    "SELECT * FROM [MyTable] WHERE ([Batch ID]=1234)"
    it works fine, returning a correct record count 120 records. If I change
    the Open SQL Statement query simply by adding an ORDER BY clause, such as:
    "SELECT * FROM [MyTable] WHERE ([Batch ID]=1234) ORDER BY [MyField] ASC"
    it returns a record count of zero. I know that "MyField" exists in the
    MyTable table and contains valid data. The
    second query works fine in SQL
    Server Enterprise Manager.
    Am I missing something? Is it true that the TestStand Open SQL Step does
    NOT support the "ORDER BY" clause? If not, what &#$!ing good is it and why
    does the manual state it is supported? Is there any other way using just
    the TestStand steps to order a database recordset on one or more fields?
    Any help would be appreciated.
    Grrrrr....
    Bob Rafuse
    Etec Inc.

    > Bob -
    > The database step types do not do anything special to the SQL command
    > that you give it. The step just passes the command to the ADO
    > provider. I tried a simple query using the step types with the
    > following command,
    >
    > "SELECT UUT_RESULT.* FROM UUT_RESULT WHERE ([UUT_SERIAL_NUMBER] =
    > 12345) ORDER BY [EXECUTION_TIME] ASC"
    >
    > and this return the expected results and the record count parameter
    > was as expected. I tried this on TS 1.0.2 and TS 2.0 with MS Access
    > 2000 and MS SQL Server 7.0. I do not have MS SQL Server 2000 at this
    > time.
    >
    > It would be surprised if the step types are messing something up.
    I've been doing some experimenting over the past couple of days. Simple,
    one-table queries seem to handle the ORDER BY clause fine. Th
    ings seem to
    get messed up when I try multi-table queries with ORDER BY clause with the
    TestStand database steps. I get no errors but the returned record counts
    are always 0 with the ORDER BY and positive without the ORDER BY. The exact
    same queries work fine in Visual Basic/ADO and the SQL Server Query
    Analyzer.
    > Questions:
    > 1. Have you verified whether the data is actually returned even though
    > the record count is zero?
    Hmmm... yes data IS getting returned (at least on the two instances I just
    checked), but the record count is always zero. I was not proceeding with
    processing if the record count was 0.
    Still... I don't know how to loop through the recordset without knowing how
    many records there are an not eventually generate an error by passing EOF.
    Is there another way using the TestStand database steps to determine a) the
    number of records in the recordset or b) when I'm at EOF?
    > 2. Are you using any advanced options on the Opend SQL Statement step
    > type, specifically
    the cursor type set to forward only? Forward only
    > cursors do not allow for record counts.
    Everything on the Advanced tab of the Open SQL Statement step is set to "Use
    Default".
    Bob.

  • INSERT Script stored as "SQL Statement Script" not firing on Oracle Alert

    We are using Alert Manager to run Alerts based on absence information in EBS R12.1.3 HR tables.
    Application: Human Resources
    Period/Event: Periodic
    Frequency: Every Day
    The Alert has 2 actions.
    One is to email a supervisor based on the Alert SQL finding staff who have had x number of absences over a set period of time.
    That is working fine.
    The other action is defined as an "SQL Statement Script".
    The SQL script inserts the variables defined in the SQL from the main Alert definition SQL, into a custom table.
    When the Alert fires, we are getting the email generated, but the INSERT statement isn't firing.
    However, when we look at the result of the Alert when it has run, and look at the steps which were fired, we can see the email step and the SQL step. When we look at the SQL in the SQL step which was generated, we can copy and paste it direct into TOAD and it works fine.
    We have tried a simple SQL INSERT statement which even just does:
    INSERT INTO xx_tmp (VALUE1_DATE, VALUE2) VALUES (SYSDATE, 'this');
    But even that does not work.
    We wonder if the issue is that we cannot do a direct INSERT from an alert type of "SQL Statement Script"?
    We have found another Alert which does a direct UPDATE on a table, but the SQL Statement Script definition has "Purchasing" as the Application, because it's updating a PO table.
    In our case, we're trying to insert into a custom table held in our in-house XX schema.
    Could the problem be that we don't have the "Application" set? If that's the case, we don't have a corresponding application anyway.
    Or can we not do a direct INSERT like this - do we need to use a package instead, and call that?
    Any advice much appreciated.
    Thanks

    Hi Brian,
    Alert issue - Custom SQL fix
    1. Define actions via "Actions" button on Alert Definition
    2. Create an action for e.g. "Send Message to Supervisor"
       Action type: message
       Action - sends email to people
    3. Create another action called e.g. "Insert Record"
       Action type: SQL Statement Script
       Fill in SQL in the "Text" section, no need to add a begin or end bit, just a simple INSERT INTO X etc ending with a semi colon
    4. Back on the main alert definition window, go to "Action Sets" button
       Here, need one SEQ for the Message / Email (e.g. Seq 1), and then click on "Action Set Details" and click on "Members" tab and select the "Send Message to Supervisor" Action
       Then close the "Action Set Details" window, and return to the "Action Sets" window
       click into 2nd line, add e.g. Seq 2, and call it e.g. "Insert Record", click on "Action Set Details" > Members tab and select the "Insert Record" The problem was that in the first instance, we had a single Action Set, and under "Members" had selected the "Send Message to Supervisor" and "Insert Record" at the same time.
    Short answer: each Action needs to be defined as a separate line in the Action Sets definition.
    I can send screenshots if you need them, and don't mind putting your email address on this forum.
    You can always edit the thread after I've emailed you, to remove your email address.

  • Group by sql statement is not sorted.

    execut sql statement include group by clause in a oci program, the result is not sorted.
    I don't know why..
    in SqlPlus, same sql statement return sorted data.
    SELECT A.SHOP_ID,A.RESALE_TYPE,
    SUM(A.DEAL_AMT,0) DEAL_AMT
    FROM SHOP_ACC A, CD_TAB C
    WHERE A.RESALE_TYPE = C.CD(+)
    AND C.GB = 'AB'
    AND A.ACC_M = :s_AccMonth
    AND DEAL_GB='FOD'
    GROUP BY A.SHOP_ID,A.RESALE_TYPE
    But, RESALE_TYPE is outer join on CD_TAB..
    if remove outer join between CD_TAB and SHOP_ACC,
    sql statement is return sorted result.
    and if modify the column RESALE_TYPE like
    RESALE_TYPE||']' or NVL(RESALE_TYPE,'AAA')
    return sorted result..
    please help..
    thanks for your kind.

    thank you.. for reply..
    I knew that order by clause make to sort.
    but, using group by clause alone in SQL statement, that return sorted results too.
    I was found a fault that outer join table CD_TAB column of one is not symbloc "(+)" in SQL statement
    SELECT A.SHOP_ID,A.RESALE_TYPE,
    SUM(A.DEAL_AMT,0) DEAL_AMT
    FROM SHOP_ACC A, CD_TAB C
    WHERE A.RESALE_TYPE = C.CD(+)
    AND C.GB = 'AB' <----------- AND C.GB(+) = 'AB'
    AND A.ACC_M = :s_AccMonth
    AND DEAL_GB='FOD'
    GROUP BY A.SHOP_ID,A.RESALE_TYPE
    I want to know that why in other application - such as SqlPlus or SqlGate and ..etc. - this fault was ignore.. but OCI application such as my application programs is not ignore.. and is not sorted..
    thank you..

  • In audit few statemntns SQL statements is not populating

    Hi,
    I enable audit,for few (SELECT,CREATE TABLE)statements audit not populating sqltext in sys.aud$.But i can see few more SELECT&CREATE TABLE activityit populates SQLTEXT.
    if it not populates sql text ,what ll be the reason behind this?

    Thank you for quick reply, Joe!
    Yes, I meant the second option with '%' symbols but still I get incorrect results. Seems that OpenSQL layer ignores the 'NOT LIKE' criterias. Any other ideas?
    I'm pasting you the log I have with the JPQL and the prepared SQL queries
    <query jpql="select distinct e, e.time.srvrStrInitTime from SlAutoGeneral e where e.status not like :status order by e.time.srvrStrInitTime desc ">
        <executeQuery>
            <prepare sql="SELECT DISTINCT E.ID E_ID_id,E.STATUS E_STATUS_status,E.SYNTH_SUBJECT E_SYNTH_SUBJECT_synthSubject,
              ALIAS_1.SRVR_STR_INIT_TIME DISPLAY_2
              FROM SL_AUTO_TIME ALIAS_1, SL_AUTO_GENERAL E WHERE ALIAS_1.ID = E.ID AND E.STATUS NOT LIKE ? ORDER BY DISPLAY_2 DESC"/>
    Best regards,
    Martin

  • UPDATE SQL statement has poor performance

    Hi All,
    We have setup regular run background process,setup to "throttle"  user submitted
    Batch Requests to Batch Processing System.  Purpose of this "Throttle" DB level background
    process  (submitted using DBMS_SCHEDULER)  to check for currently active Requests and
    then accordingly (based on prevailing System Load)   inject new requests for Batch Request accordingly.
    This background process is scheduled to run every minute.
    We find that UPDATE statement below performs well when Table being updated (FRM_BPF_REQUEST)
    even when Table has upto 1 million rows.  (Expected Production volume)  UPDATE takes only few seconds  (< 10 secs)
    at most to execute
    However, we find that when there is a burst of INSERTS happening to  same Table  (FRM_BPF_REQUEST)
    via another database session,  UPDATE statement suffers with severe degradation.  Same UPDATE which used
    to perform  in matter of few seconds, takes upto  40 minutes when heavy INSERTS are happenning to
    Table.  We are trying to understand why Performance gets severely degraded when INSERTS are heavy on the Table,
    Any thoughts or insights into issue would be greatly appreciated.
    We are using Oracle DB 11.2.0.3.4  (on Linux)
    CREATE OR REPLACE PROCEDURE BPF_DISPATCH_REQUEST_SP(V_THROTTLE_SIZE NUMBER DEFAULT 600) AS
    --    Change History
    --001 -Auro    -10/09/2013  -Initial Version
    --    v_throttle_size    NUMBER DEFAULT 600;
          v_active_cnt         NUMBER DEFAULT 0;
          v_dispatched_cnt   NUMBER DEFAULT 0;
        v_start_time    TIMESTAMP := SYSTIMESTAMP;
        v_end_time    TIMESTAMP;
            v_subject_str   VARCHAR2(100) := '';
            v_db_name       VARCHAR2(20) := '';
      BEGIN
        -- Determine Throttle Size
        SELECT THROTTLE_SIZE
        INTO   v_throttle_size
        FROM   FRM_BPF_REQUEST_CONTROL;
        -- Determine BPF Active Request Count
        SELECT COUNT(*)
        INTO   v_active_cnt
        FROM   FRM_BPF_REQUEST
        WHERE  STATUS IN('rm_pending','rm_ready','processing','worker_ready','failed','dependency_failed','recover_ready');
        IF v_active_cnt < v_throttle_size THEN
            UPDATE FRM_BPF_REQUEST
            SET    STATUS='dispatched'
            WHERE  ID IN (
                    SELECT ID FROM (
                   SELECT ID
                   FROM   FRM_BPF_REQUEST
                   WHERE  STATUS='new'
                   ORDER BY ID
                    ) WHERE ROWNUM <= (v_throttle_size - v_active_cnt)
            v_dispatched_cnt := SQL%ROWCOUNT;
            COMMIT;
        END IF;
         v_end_time := SYSTIMESTAMP;
        INSERT INTO FRM_BPF_REQUEST_DISPATCH_LOG
        VALUES (
            v_start_time,   
            v_active_cnt,
            v_dispatched_cnt,
            v_end_time,
            NULL
        COMMIT;
        EXCEPTION
                  WHEN OTHERS THEN
                ROLLBACK;
             v_end_time := SYSTIMESTAMP;
            INSERT INTO FRM_BPF_REQUEST_DISPATCH_LOG
            VALUES (
                v_start_time,   
                v_active_cnt,
                v_dispatched_cnt,
                v_end_time,
                NULL
            COMMIT;
                SELECT ORA_DATABASE_NAME
            INTO   v_db_name
            FROM   DUAL;
                   v_subject_str := v_db_name||' DB: Fatal Error in BPF Request Dispatch Process';
            -- Alert Support                   
                DBA_PLSQL.SEND_MAIL(P_RECIPIENTS     => '[email protected]',
                                        P_CC         => '[email protected]',
                                            P_BCC         => '[email protected]',
                                            P_SUBJECT         => v_subject_str,
                                            P_BODY         => SUBSTR(SQLERRM, 1, 250));
    END;
    show errors
    Thanks
    Auro

    What the heck is this:
      EXCEPTION
                  WHEN OTHERS THEN
                ROLLBACK;
             v_end_time := SYSTIMESTAMP;
            INSERT INTO FRM_BPF_REQUEST_DISPATCH_LOG
            VALUES (
                v_start_time,   
                v_active_cnt,
                v_dispatched_cnt,
                v_end_time,
                NULL
            COMMIT;
                SELECT ORA_DATABASE_NAME
            INTO   v_db_name
            FROM   DUAL;
                   v_subject_str := v_db_name||' DB: Fatal Error in BPF Request Dispatch Process';
            -- Alert Support                   
                DBA_PLSQL.SEND_MAIL(P_RECIPIENTS     => '[email protected]',
                                        P_CC         => '[email protected]',
                                            P_BCC         => '[email protected]',
                                            P_SUBJECT         => v_subject_str,
                                            P_BODY         => SUBSTR(SQLERRM, 1, 250));
    Why are you programming for failure to succeed, willing to accept time taking rollbacks, committing afterward, fooling with transactions, swallowing/hiding all errors, all that 'nice and safely hidden' in the notorious WHEN OTHERS exception NOT followed by a RAISE?
    Only catch errors you expect.
    Programming to let a program fail is to fail.

  • Auditing: Flushing SGA to ensure SQL statement is not cached

    Currently I'm experimenting with Oracle auditing and have noticed that when I audit an object, like a table (AUDIT SELECT ON MY_TABLE), the select on the table is audited only once per session. I.e. When a user connects, and does:
    SQL> select * from my_table;
    SQL> ..
    SQL> ..
    SQL> select * from my_table;
    SQL> ..
    SQL> ..
    .. only the first select statement is audited. I have to reconnect each time for the statement to be audited.
    Is this how auditing works? I was thinking that it could be that the statement is held in memory and when a user does another subsequent select statement, the statement is cached and thus not audited. Could this be the case? I flushed the SGA and I still got the same results above...
    I'd like to hear your opinions about this.

    Raj has provided the solution but I would like to point out that auditing selects by access can generate an alful lot of audit records very quickly. The sys.aud$ table and its index may grow very, very large and fill the system tablespace if you are not careful. Also the updates to sys.aud$ are logged so you will also be generating a lot of extra redo if you make this type of auditing widespread.
    IMHO -- Mark D Powell --

  • Iif() sql statement is not working please help. An expression of non boolean type specified the context

    the following sql is not working . If  sum(salary) = null   should be displayed  1 or 0
    select empname,iif((isnull(sum(salary),0)),1,0) from salary group by empname
    regards
    Pol
    polachan

    I think what you're looking at is this
    select e.empname,
    COALESCE(s.totalsal,0) as salary
    from employee e
    left join (select empname,sum(salary) as totalsal
    from salary
    group by empname
    )s
    on s.empname = e.empname
    where employee represents your master table containing employee information
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • 'lag' works in normal SQL statement, but not when in a view (resolved)

    hi,
    got a problem when using 'lag' in a view.
    if i set up a select statement using 'lag' and execute it, all the results are correct.
    when i stick the exact same select into a view, then the results for the 'lag' entries are not correct any more.
    has anyone experienced this ?
    any hints would be good.
    thanks
    Martin
    using Oracle 10g Express
    version 10.2.0.1.0
    can not download the patch because i can not log into metalink - no CSI
    setting to resolved.
    Message was edited by:
    user614086

    Hi again,
    I think the problem is more with your expectation of what LAG should be doing than with LAG itself.
    LAG must calculate based on the result set, in your stand alone query that means what's left after the WHERE clause is applied.
    In the view that means across all rows the view produces. THEN you apply the where clause to the calculated values. You can see this in the example below.
    So what you'd need to do is define this view in a manner in which the WHERE clause won't make a difference to the logical window produced.
    That would mean using some columns in the partition by clause and order by clause, or leaving the lag function outside the view.
    create table test_lag (column1 number, column2 varchar2(10), column3 date);
    insert into test_lag values (1, 'ONE', trunc(sysdate,'DD') - 1);
    insert into test_lag values (2, 'TWO' trunc(sysdate,'DD') );
    insert into test_lag values (3, 'THREE', trunc(sysdate,'DD') + 1);
    insert into test_lag values (4, 'FOUR', trunc(sysdate,'DD') + 2);
    commit;
    create or replace view test_lag_v
    as
    select column1, column2, lag(column2, 1) over (order by column1 asc) AS laggery, lag(column1) over (order by column3 desc) as laggery_2
    from test_lag;
    ME_XE?select *
      2  from test_lag_v
      3  where column1 <> 3;
               COLUMN1 COLUMN2                        LAGGERY                                 LAGGERY_2
                     4 FOUR                           THREE
                     1 ONE                                                                            3
    2 rows selected.
    Elapsed: 00:00:00.50
    ME_XE?
    ME_XE?select *
      2  from test_lag_v;
               COLUMN1 COLUMN2                        LAGGERY                                 LAGGERY_2
                     4 FOUR                           THREE
                     3 THREE                          ONE                                             4
                     1 ONE                                                                            3
    3 rows selected.
    Elapsed: 00:00:00.68

  • User can Execute SQL Statement but not Stored Procedure

    I have a function in Access that calls a stored procedure to update a table. When I run it, it works fine but when the users try to run it, they get an error.
    If I change it run the actual SQL syntax that is in the stored procedure then the users can run it and update the table without any problems, which makes no sense to me. It's doing the same exact thing as the stored procedure. I'd much rather have them be
    able to run the procedures then writing the SQL in VBA modules because that's going to end up being a lot of code.
    Any idea on why it's like this and how to correct it? Any assistance would be appreciated.

    Hello,
    When you give a user permission to run a stored procedure, everything on that procedure but Dynamic SQL will be executed
    without evaluating user permissions on the objects the stored procedure deals with.
    On the link I provided above, you will see how to provide permissions to stored procedures. Try creating database roles, add user to database roles, then assign permissions to database roles.
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • Fetching SQL statements is not supported for this report.

    Post Author: Adam20002
    CA Forum: .NET
    I am using the following code to try and get the SQL string of a report in code. This works for all our reports apart from one which gives us the above error message. The code we are using is as follows:-
    rptDoc.ReportClientDocument.RowsetController.GetSQLStatement(Nothing)
    Can anyone give me any clues as to why this works for all the other reports and what i might need to check for this one particular report. There is noting special about the report it just gets detials from a few tables, no supreports, fancy formulas or anything.

    Post Author: Adam20002
    CA Forum: .NET
    I am using the following code to try and get the SQL string of a report in code. This works for all our reports apart from one which gives us the above error message. The code we are using is as follows:-
    rptDoc.ReportClientDocument.RowsetController.GetSQLStatement(Nothing)
    Can anyone give me any clues as to why this works for all the other reports and what i might need to check for this one particular report. There is noting special about the report it just gets detials from a few tables, no supreports, fancy formulas or anything.

Maybe you are looking for