SQL Statement -- Throws GROUP BY issue on NVL

Hey All,
This is pretty much my first time tackling a very complex SQL Statement but the boss is adamant about it.
Anyways here is the information. I have 3 Tables. Table one Contains Work Order Infromation that will be listed or grouped. Table 2 and Table 3 house information that needs to be summed (Estimate hours and Actual Hours).
So my SQL Statement looked something like this... (Its a mess)
select workorder.wolo3, workorder.wojp1, workorder.wonum, workorder.description, workorder.location, workorder.status, workorder.wopriority, workorder.targstartdate, workorder.reportdate, workorder.pmnum, workorder.schedstart, sum(labtrans.regularhrs + labtrans.premiumpayhours) as actualhours, sum(wplabor.quantity * wplabor.laborhrs) as estimatehrs
from maximo.workorder left outer join maximo.labtrans on labtrans.regularhrs > 0 and labtrans.refwo = workorder.wonum and labtrans.siteid = workorder.siteid or labtrans.premiumpayratetype = 'MULTIPLIER' and labtrans.refwo = workorder.wonum and labtrans.siteid = workorder.siteid left outer join maximo.wplabor on wplabor.wonum = workorder.wonum and wplabor.siteid = workorder.siteid
where workorder.istask=0 and workorder.siteid='NTS' and workorder.status in ('INPRG','SCHED') and workorder.crewid in ('MAINT','DAF') and workorder.schedstart <= TO_DATE('12-13-2009','MM-DD-YYYY') and wolo3 is not null group by workorder.wonum, workorder.status, workorder.wopriority, workorder.pmnum, workorder.location, workorder.description, workorder.targstartdate, workorder.reportdate, workorder.schedstart, workorder.wolo3, workorder.wojp1
Now the problem is that the 2nd sum (Estimate Hrs) gets HUGE numbers if there are multiple rows in Actual Hours. So I did some searching. Seems that if I used the NVL function in the SQL Statement it would fix the issue...
select workorder.wolo3, workorder.wojp1, workorder.wonum, workorder.description, workorder.location, workorder.status, workorder.wopriority, workorder.targstartdate, workorder.reportdate, workorder.pmnum, workorder.schedstart, sum(labtrans.regularhrs + labtrans.premiumpayhours) as actualhours,
nvl((select sum(wplabor.quantity * wplabor.laborhrs) from maximo.wplabor where wplabor.wonum = workorder.wonum and wplabor.siteid = workorder.siteid),0)
from maximo.workorder left outer join maximo.labtrans on labtrans.regularhrs > 0 and labtrans.refwo = workorder.wonum and
labtrans.siteid = workorder.siteid or labtrans.premiumpayratetype = 'MULTIPLIER' and labtrans.refwo = workorder.wonum and
labtrans.siteid = workorder.siteid
where workorder.istask=0 and workorder.siteid='NTS' and workorder.status in ('INPRG','SCHED') and
workorder.crewid in ('MAINT','DAF') and workorder.schedstart <= TO_DATE('12-13-2009','MM-DD-YYYY') and wolo3 is not null
group by workorder.wonum, workorder.status, workorder.wopriority, workorder.pmnum, workorder.location, workorder.description, workorder.targstartdate, workorder.reportdate, workorder.schedstart, workorder.wolo3, workorder.wojp1
However If get the error not a GROUP BY expression.
I really need this to work. How can I get the NVL to work with out having to define a Group for it. The problem is that it is a "alias column" and you cannot Group by those fields. Frustation sets in... UGH!
Thanks in Advance, Ben.

Hi, Ben,
Wlecome to the forum!
user12273726 wrote:
So my SQL Statement looked something like this... (Its a mess)You're right. Fix that first.
Put each SELECT item, each condition, and each GROUP BY expression on a separate line. Indent to show here the clauses (SELECT, FROM, WHERE) are.
For example:
SELECT    workorder.wolo3
,       workorder.wojp1
,       workorder.wonum
,       workorder.description
,       workorder.location
,       workorder.status
,       workorder.wopriority
,       workorder.targstartdate
,       workorder.reportdate
,       workorder.pmnum
,       workorder.schedstart
,       SUM (labtrans.regularhrs + labtrans.premiumpayhours)     AS actualhours
,       SUM (wplabor.quantity * wplabor.laborhrs)          AS estimatehrs
FROM                  maximo.workorder
LEFT OUTER JOIN   maximo.labtrans     ON      labtrans.regularhrs         > 0
                                   AND     labtrans.refwo              = workorder.wonum
                         AND     labtrans.siteid              = workorder.siteid
                         OR     labtrans.premiumpayratetype = 'MULTIPLIER'     -- WARNING!  Don't mix AND and OR
                         AND     labtrans.refwo              = workorder.wonum
                         AND     labtrans.siteid              = workorder.siteid
LEFT OUTER JOIN   maximo.wplabor     ON     wplabor.wonum              = workorder.wonum
                                   AND     wplabor.siteid              = workorder.siteid
WHERE     workorder.istask      = 0
AND       workorder.siteid       = 'NTS'
AND       workorder.status       IN ('INPRG','SCHED')
AND       workorder.crewid       IN ('MAINT','DAF')
AND       workorder.schedstart   <= TO_DATE ('12-13-2009','MM-DD-YYYY')
AND       wolo3                       IS NOT NULL
GROUP BY  workorder.wonum
,            workorder.status
,       workorder.wopriority
,       workorder.pmnum
,       workorder.location
,       workorder.description
,       workorder.targstartdate
,       workorder.reportdate
,       workorder.schedstart
,       workorder.wolo3
,       workorder.wojp1
;When you post formatted text on this site, type these 6 characters:
&#123;code&#125;
(small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.
Now the problem is that the 2nd sum (Estimate Hrs) gets HUGE numbers if there are multiple rows in Actual Hours. Huge numbers are not necessarily wrong. Do yo mean the numbers computed by your query are much bigger than they are supposed to be?
So I did some searching. Seems that if I used the NVL function in the SQL Statement it would fix the issue...
select workorder.wolo3, workorder.wojp1, workorder.wonum, workorder.description, workorder.location, workorder.status, workorder.wopriority, workorder.targstartdate, workorder.reportdate, workorder.pmnum, workorder.schedstart, sum(labtrans.regularhrs + labtrans.premiumpayhours) as actualhours,
nvl((select sum(wplabor.quantity * wplabor.laborhrs) from maximo.wplabor where wplabor.wonum = workorder.wonum and wplabor.siteid = workorder.siteid),0)
...It looks like you have a Chasm Trap, where you have multiple, independent one-to-many relationships on the same table, and the solution to aggregate them in separate queruies.
It looks like you're trying to aggregate wplabor in scalar sub-queries, which makes the GROUP BY more complicated (as you discovered), and is also very inefficient.
It would be easier to code and more efficient to run if you aggregated wplabor in a sub-query, and then joined to this sub-query (and not the actual wplabor table) in your main query.
If you'd like help, post a little sample data (CREATE TABLE and INSERT statements) for all three tables, and the results you want from that data.
Simplify as much as possible. Instead of GROUPing BY 11 columns, just GROUP BY, say, 3 columns: the 2 involved in the join condidiotns, and one more. Once you understand how to do this, adding the other expressions will be trivial.
You can also simplify by ignoring, for now, the WHERE clause, and, therefore, the columns involved in the WHERE clause. It looks like that has nothing to do with the problem. Again, adding the conditions later will be trivial.

Similar Messages

  • Case Statement and Group By issues

    Hi this is my initial query which works perfectly:
    select ff.cla_case_no, Cost_before_Decision, Cost_Of_Claim, decline, Decline_Description from
    fraud_nov_14_final ff
    ,(select cla_case_no, (sum(total_cost_adj_old) + sum(decline_estimate)) Cost_before_Decision
    from reporting.ci_final@test
    group by cla_case_no) z
    where ff.cla_case_no = z.cla_case_noI now want to add in a condition based on a column called decline:
    select ff.cla_case_no, Cost_before_Decision, Cost_Of_Claim, ff.decline, Decline_Description from
    fraud_nov_14_final ff
    ,(select cla_case_no, (case when decline = 1 or decline = 2  THEN (sum(total_cost_adj_old) + sum(decline_estimate)) ELSE Total_Cost END) Cost_before_Decision
    from reporting.ci_final@test
    group by cla_case_no) z
    where ff.cla_case_no = z.cla_case_noThe error message I receive is :
    ORA-00979: not a GROUP BY expression
    00979. 00000 - "not a GROUP BY expression"
    Thanks in advance for your help!!
    Banner:
    Oracle Database 11g Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    "CORE 11.2.0.2.0 Production"
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production

    You would need DECLINE in the group by clause of your inner query.
    Additionally you would need to change TOTAL_COST to SUM(TOTAL_COST) in where case statement.
    But then you would retrieve one row for each value of DECLINE in this query.
    You also could use this:
    (I don't know if it will meet your requirements)
    SELECT ff.cla_case_no,
                     cost_before_decision,
                     cost_of_claim,
                     ff.decline,
                     decline_description
      FROM fraud_nov_14_final ff,
                     (SELECT   cla_case_no,
                               SUM (decode(decline,1,total_cost_adj_old+decline_estimate,
                                                   2,total_cost_adj_old+decline_estimate,
                                                   total_cost))  cost_before_decision
                                    FROM reporting.ci_final@test
                      GROUP BY cla_case_no) z
    WHERE ff.cla_case_no = z.cla_case_no;(untested code, because I don't have your tables)
    Edited by: hm on 23.11.2011 06:52

  • 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..

  • Group By in sql statement....

    I have the following sql statement:
    SELECT ROWNUM AA, EPONYMO||' '||ONOMA FNAME ,CODE_ERGAZOMENOY_TYPE_ID,MV_SIGK_KATAST_MINA.SUM_ODOIP_EXODA,
    MV_SIGK_KATAST_MINA.SUM_HMERISIA_APOZIMIOSI, MV_SIGK_KATAST_MINA.SUM_SINOLO,
    MV_SIGK_KATAST_MINA.SUM_KRATISI_MTPY,
    MV_SIGK_KATAST_MINA.SUM_KRATISI_G_EPIM, MV_SIGK_KATAST_MINA.SUM_KRATISI_TADKY,
    MV_SIGK_KATAST_MINA.ETOS , (SELECT NVL(SUM(DAYS),0) FROM MOD3_PRAGMATOP_ODOIP WHERE
    CODE_ERGAZOMENOY_TYPE_ID=MV_SIGK_KATAST_MINA.CODE_ERGAZOMENOY_TYPE_ID AND
    MINAS||'/'||ETOS BETWEEN :P_MONTH_APO||'/'||:P_ETOS_APO AND :P_MONTH_EOS||'/'||:P_ETOS_EOS) PRAGM_ODOIP ,
    (SELECT DAYS FROM REF_DIKAIOUM_MERES_EKTOS_EDRAS
    WHERE SYSDATE BETWEEN DATES_APO AND DATES_EOS AND
    SEQ_CODE_ERGAZOMENOY_TYPE_ID=MV_SIGK_KATAST_MINA.CODE_ERGAZOMENOY_TYPE_ID) DIKAIOUM_ODOIP , MV_SIGK_KATAST_MINA.SUM_SINOLO-(MV_SIGK_KATAST_MINA.SUM_KRATISI_MTPY+MV_SIGK_KATAST_MINA.SUM_KRATISI_G_EPIM+MV_SIGK_KATAST_MINA.SUM_KRATISI_TADKY) NET_POSO
    FROM MV_SIGK_KATAST_MINA  , REF_ERGAZOMENOS
    WHERE REF_ERGAZOMENOS.SEQ_CODE_ERGAZOMENOY=MV_SIGK_KATAST_MINA.CODE_ERGAZOMENOY_TYPE_ID
      AND MV_SIGK_KATAST_MINA.MINAS||'/'||MV_SIGK_KATAST_MINA.ETOS BETWEEN :P_MONTH_APO||'/'||:P_ETOS_APO AND :P_MONTH_EOS||'/'||:P_ETOS_EOS
    and i want to compute the sum of the above selected columns adding a group by clause.....Is it possible.....?????
    Some sample data...
    MINAS     ETOS     CODE_ERGAZOMENOY_TYPE_ID     SUM_ODOIP_EXODA     SUM_HMERISIA_APOZIMIOSI     SUM_SINOLO     SUM_KRATISI_MTPY     SUM_KRATISI_G_EPIM     SUM_KRATISI_TADKY
    07     2007     161     505,95     508,64     972,74     10,32     25,48     20,28
    07     2007     230     85,3     78,25     163,55     1,59     3,92     3,12
    06     2007     230     0     9,78     9,78     0     0     0
    06     2007     161     421,75     254,31     676,06     5,17     12,74     10,14
    07     2007     26     118,35     303,21     330,81     6,17     15,19     12,09
    05     2007     230     0     9,78     9,78     0     0     0
    07     2007     236     328,25     88,04     407,04     1,78     4,41     3,51I use OracleDB10g...
    Sorry for the format of the sample data.....!!!!
    Thanks, a lot
    Simon
    Message was edited by:
    sgalaxy

    To columns... which do have the 'SUM_' prefix ....such as ...
    EPONYMO||' '||ONOMA ,
    CODE_ERGAZOMENOY_TYPE_ID,
    MV_SIGK_KATAST_MINA.ETOS,
    PRAGM_ODOIP (nested select query),
    DIKAIOUM_ODOIP (nested select query)
    I THINK... I HAVE DONE IT... I'LL CHECK IT MORE CAREFULLY...
    Thanks...a lot
    Simon
    Message was edited by:
    sgalaxy

  • Dynamically Identifying user issuing SQL statement

    Client wants to provide security to certain data by first capturing the identity of every user issuing a SQL statement, then, based on the user and a security table, allow access to certain data. Is this doable? TIA...

    Oracle has a whole product centered around this called "Label Seurity", which I'm guessing may be too much for your needs. Check out this marking shag for info about "virtual private databases" http://technet.oracle.com/deploy/security/oracle8i/pdf/vpd_wp6.pdf
    Basically, the idea is that the "old school", but still perfecly fine, way to do it is to create views for each group of users and grant permissions to the views for the appropriate users. Optionally using synomyms into their schemas to give users the same name for the different views.
    The virtual private database and similar stuff is hard to explain. I think of it as the db engine auto-adding a where clause to each sql statement based upon who you are. If that makes any sense.
    I've tried this a couple of different ways, but have yet to hit upon one that seems easy & generally applicable.
    Good Luck -d

  • Using Native Query to run a SQL statement, the "getResultList" throws excep

    I run the following code and I get an exception, can someone tell me what I'm doing wrong? I tried debugging, but as soon as I try even stepping into the "getResultList" line, it throws the exception.
    public void setData(EntityManager emgr) {
    System.err.println(m_sqlStatement);
    Query q = emgr.createNativeQuery(m_sqlStatement);
    @SuppressWarnings("unchecked")
    List<List<Object>> c = q.getResultList();
    for (List<Object> d : c) {
    if (d == null || d.isEmpty()) {
    continue;
    addRow(d.toArray());
    }I took this sql statement and created a test view and ran it against my database and I get the data that I want the way that I want it. So, I feel pretty confident that the problem is not with my sql statement.
    m_sqlStatement =
    SELECT TimeSubmitted AS "Time Completed", ActivityName AS "Activity", PN AS "Part Number", OpNum AS "Op Num", isConforming AS "Conforming?", SetupHrs AS "Expected Setup Time (Hrs.)", RunHrs AS "Expected Run Time (Hrs.)" FROM CellManager INNER JOIN Routings ON Routings.ID=CellManager.RoutingsRef INNER JOIN PNTable ON PNTable.ID=Routings.PNRef INNER JOIN ActivityType ON ActivityType.ID=CellManager.ActivityTypeRef INNER JOIN Activity ON Activity.CellManagerRef=CellManager.ID WHERE CellManager.OperatorLogRef=15 Order BY TimeSubmitted
    Exception thrown:
    SEVERE: Application class productionefficiencyviewergui.ProductionEfficiencyViewerGUIApp failed to launch
    Local Exception Stack:
    Exception [TOPLINK-6132] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.QueryException
    Exception Description: Query argument " not found in list of parameters provided during query execution.
    Query: DataReadQuery(){code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    I run the following code and I get an exception, can someone tell me what I'm doing wrong? I tried debugging, but as soon as I try even stepping into the "getResultList" line, it throws the exception.
    public void setData(EntityManager emgr) {
    System.err.println(m_sqlStatement);
    Query q = emgr.createNativeQuery(m_sqlStatement);
    @SuppressWarnings("unchecked")
    List<List<Object>> c = q.getResultList();
    for (List<Object> d : c) {
    if (d == null || d.isEmpty()) {
    continue;
    addRow(d.toArray());
    }I took this sql statement and created a test view and ran it against my database and I get the data that I want the way that I want it. So, I feel pretty confident that the problem is not with my sql statement.
    m_sqlStatement =
    SELECT TimeSubmitted AS "Time Completed", ActivityName AS "Activity", PN AS "Part Number", OpNum AS "Op Num", isConforming AS "Conforming?", SetupHrs AS "Expected Setup Time (Hrs.)", RunHrs AS "Expected Run Time (Hrs.)" FROM CellManager INNER JOIN Routings ON Routings.ID=CellManager.RoutingsRef INNER JOIN PNTable ON PNTable.ID=Routings.PNRef INNER JOIN ActivityType ON ActivityType.ID=CellManager.ActivityTypeRef INNER JOIN Activity ON Activity.CellManagerRef=CellManager.ID WHERE CellManager.OperatorLogRef=15 Order BY TimeSubmitted
    Exception thrown:
    SEVERE: Application class productionefficiencyviewergui.ProductionEfficiencyViewerGUIApp failed to launch
    Local Exception Stack:
    Exception [TOPLINK-6132] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.QueryException
    Exception Description: Query argument " not found in list of parameters provided during query execution.
    Query: DataReadQuery(){code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Group by in a SQL statement

    I have this SQL Statement
    SELECT PTE.PLT_SHORT_NAME PLT_SHORT_NAME,
    COUNT ( * ) SEGMENTS,
    COUNT ( DECODE ( SUBSTR ( TE.EVAL_RESULT , 1 , 1 ) , 'Y' , 1 , NULL ) ) SEGMENTS_COMPLY,
    COUNT ( DECODE ( SUBSTR ( TE.EVAL_RESULT , 1 , 1 ) , 'N' , 1 , NULL ) ) SEGMENTS_NO_COMPLY,
    SUM ( DECODE ( SUBSTR ( TE.EVAL_RESULT , 1 , 1 ) , 'Y' , ( TE.ACTUAL_DURA - ( TE.EXPCT_DURA ) ) , 0 ) ) TIEMPO_GANADO,
    ( ( COUNT ( DECODE ( SUBSTR ( TE.EVAL_RESULT , 1 , 1 ) , 'Y' , 1 , NULL ) ) / COUNT ( * ) ) * 100 ) || '%' COMPLY_PERCENT,
    SUM ( DECODE ( SUBSTR ( TE.EVAL_RESULT , 1 , 1 ) , 'N' , ( TE.ACTUAL_DURA - ( TE.EXPCT_DURA ) ) , 0 ) ) TIEMPO_PERDIDO,
    ( SUM ( DECODE ( SUBSTR ( TE.EVAL_RESULT , 1 , 1 ) , 'Y' , ( TE.ACTUAL_DURA - ( TE.EXPCT_DURA ) ) , 0 ) ) + SUM ( DECODE ( SUBSTR ( TE.EVAL_RESULT , 1 , 1 ) , 'N' , ( TE.ACTUAL_DURA - ( TE.EXPCT_DURA ) ) , 0 ) ) ) DIFERENCIA
    FROM PLT_TRN_EVALS PTE,
    TRN_EVALS TE,
    TRN_EVENT_TIMES_HEADERS TETH
    WHERE ( /* CG$MDTU_QWC_START Q_1.PTE */
    (PTE.PLT_SHORT_NAME IS NOT NULL AND PTE.DELETED = 'N')
    /* CG$MDTU_QWC_END Q_1.PTE */
    ) AND
    ( /* CG$MDTU_QWC_START Q_1.TE */
    (TE.TYP = 'SEG' AND TE.DELETED = 'N')
    /* CG$MDTU_QWC_END Q_1.TE */
    ) AND
    PTE.TE_SEQ = TE.SEQ AND
    ( /* CG$MDTU_QWC_START Q_1.TETH */
    (TETH.DELETED = 'N' AND TETH.SCHED_DATE BETWEEN :P_DATE_FROM AND :P_DATE_TO)
    /* CG$MDTU_QWC_END Q_1.TETH */
    ) AND
    TE.TETH_SEQ = TETH.SEQ
    GROUP BY PTE.PLT_SHORT_NAME
    And I would like to know, how can I include the GROUP BY in order to generate

    I think your question got cut off. What are you trying to generate with this SQL? I should say in advance that Oracle Designer has very few places where you can enter a SELECT command directly. You can usually get it to generate what you need by choosing the correct Table Definition (or View Definition) usages, choosing the display columns you want, and adding WHERE clauses and GROUP BY columns.
    With something as complex as your Statement, I would probably consider creating a View, then use the View in modules.

  • Issue Related to limit the result in prompt by using SQL statement.

    Hello Gurus,
    I am facing one issue rite now with our testing environment in some Dashboard Prompt. it seems like they are working fine in our Development environment.
    basically I am using SQL statement in prompt to limit the values for current + last 2 years in drop down.
    Here is the SQL that I am using SELECT Time."Fiscal Year" FROM "Financials - AP Overview" where Time."Fiscal Year" <= VALUEOF(NQ_SESSION.CURRENT_FSCL_YEAR) AND Time."Fiscal Year" >= (VALUEOF(NQ_SESSION.CURRENT_FSCL_YEAR)-2) ORDER BY TIme."Fiscal Year" desc
    Now it's working fine in our Dev but geeting failed in Test environment.
    it's giving below error.
    Odbc driver returned an error (SQLExecDirectW).
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred.
    [nQSError: 43113] Message returned from OBIS.
    [nQSError: 43119] Query Failed:
    [nQSError: 22023] An arithmetic operation is being carried out on a non-numeric type. (HY000)
    SQL Issued: SELECT Time."Fiscal Year" FROM "Financials - AP Overview" where Time."Fiscal Year" <= VALUEOF(NQ_SESSION.CURRENT_FSCL_YEAR) AND Time."Fiscal Year" >= (VALUEOF(NQ_SESSION.CURRENT_FSCL_YEAR)-2) ORDER BY TIme."Fiscal Year" desc
    Please let me know your output.
    Thanking You..

    Couple of possibilities..
    1. environments may be at different patch sets, may be causing the issue.
    2. data in working environment is fine but in other environment.
    to further debug use the same logical sql in both environments and compare the results..
    hope this helps..

  • Issue on execute multiple SQL Statement on MySQL

    Hi,I plan to execute dozenes of INSERT SQL statement on MySQL by JDBC:org.gjt.mm.mysql.Driver,But it throws the unkown exeption,pls kindly help
    The code is like the follwoing
    sql="insert into TEST values('100','test') ";
    stmt=cnMySQL.createStatement();
    stmt.addBatch(sql);
    stmt.addBatch(sql);
    stmt.executeBatch();
    //stmt.executeUpdate(sql);

    The Exception is very tough,paste for all
    javax.servlet.ServletException
         at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:497)
         at org.apache.jsp.testBean_jsp._jspService(testBean_jsp.java:293)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
         at java.lang.Thread.run(Thread.java:484)
    I have tried another way to execute multiple SQL.But the same Exception ocurred.
    String sql="insert into TEST('100','100V'); "+
    "insert into TEST('100','100V') ";
    stmt.executeUpdate(sql);
    Can't it the jdbc of MM support this kind of operation? And is there any better JDBC for mySQL?
    Apprieciated for all!!!

  • How to monitor  SQL statements issued by SIEBEL ?

    Hi,
    We have developed BI Siebel 10.1.3.3. application.
    One of the requirement is to persist/store in the database real SQL statement issued by BI Dashboards/Answers.
    The best solution would be having acces on-line to cursor cache.
    Could someone please tell me how to achive this ?
    Regards,
    Cezary

    Sounds like you're looking for Usage Tracking.
    OBIEE Server Administration Guide – Pages: 220
    OBIEE Installation and Configuration Guide – Pages: 229
    And this post here;
    http://oraclebizint.wordpress.com/2007/08/14/usage-tracking-in-obi-ee/
    A.

  • Why below MERGE sql statement is throwing error  on 10g?

    Version: Ora 10g R2
    Why below MERGE sql statement is throwing error on 10g?
    SQL> merge into sess_stats
    using
    select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=:sid  and (a.name like '%ga %' or a.name like '%direct temp%')
    ) curr_stats
    on (sess_stats.name=curr_stats.name)
    when matched then
         update set diff=curr_stats.value-sess_stats.value, value=curr_stats.value
    when not matched then
         insert (name, value, diff) values (curr_stats.name, curr_stats.value, null)  2    3    4    5    6    7    8  SQL> SP2-0734: unknown command beginning "on (sess_s..." - rest of line ignored.
    SQL> SP2-0734: unknown command beginning "when match..." - rest of line ignored.
    SQL>   2    3

    First of all, thank you all for your feedback!
    first, I try remove the blank lines at those two places ( before curr_stats and after on) and it works.
    then, again I try to set sqlblanklines on, and it works as well!
    Edited by: PhoenixBai on Nov 10, 2009 10:54 PM

  • Trace SQL statement issued by BC4J

    Is there a way to see at runtime (in the console window or in a log file) the SQL statements issued by the BC4Js to the database?
    Perhaps there is a switch or a -D option to set to the OC4J startup command. This would be really helpfull during development.
    Thanks,
    Marco.

    Yes, you are right. that will be done by specify a Java virtual parameters - -Djbo.debugoutput=console.

  • New sessions every time an sql statement is issued

    Hi, I have a problem with using oraoledb (v 10.1.0) with VB6 accessing an Oracle database 9i (v 9.2.0.6). Every time an sql statement is issued in the client side, a new session is started in the server side (seen in Enterprise Manager). I don´'t know why. Is an oraoledb parameter or a database parameter? How can I avoid this? The big problem behind this behaviour is controling row locking. If I issue a "select field from table where conditions for update nowait(or wait n)", this creates a lock that belongs to a session. If a few sentences after I issue an "update the-same-table set the-same-field = value where the-same-condition" as this one creates a new session, an ORA-00054 is raised telling the row(s) is blocked.
    any idea?
    thanks

    I'm a DBA and I encountered the same problem with a system developed for our company. We reported that to the company that developed the application and they sey then close the conections, but they remain in the database.
    Could anyone find a solution for this? I believe is a problem in the VB code, but I do not know anything from VB.
    thanks,
    Lisandro

  • Finding the issued SQL statement

    Hi All,
    A user has issued this:
    DROP USER user CASCADE;
    and after a while it got hung up.
    Since all database users are using the same schema, I can not find the sid/serial # to kill it. There are many users in active and inactive status are found but could not identify the user who issued the above sql.
    I know I can extract sid,serial# through v$session view. How can I join this view with other views to identify the sql statement?
    Do you know how?
    Thanks,

    To get the SID and SERIAL # please execute the SQL below:
    set lin 500
    col username format a15
    col terminal format a15
    col program format a40
    col machine format a25
    select s.paddr, p.spid, s.sid,s.serial#,s.terminal,s.machine,s.username,s.status,s.process,s.program,s.module,s.action, s.server from v$session s, v$process p
    where p.addr=s.paddr
    order by s.sid
    To get the SQL Statement you have to get the SID and SERIAL # from above statement and execute the SQL below:
    select x.sql_text from v$sql x, v$session y
    where x.hash_value = y.sql_hash_value
    and x.address = y.sql_address
    and y.sid = &sid
    /

  • SQL statement performance issues

    Hi: A sql statement I have is taking too long to complete. But if I break the statement into two separate statements, it runs fine.
    SQL 1 runs fine and returns 163.
    SELECT /*+ FIRST_ROWS */ entity_group.entity FROM auth, entity_group, user_group WHERE entity_group.auth_group = user_group.groupid and user_group.userid = auth.id and auth.username = 'ing';
    SQL 2 runs fine, prints about 20 records
    select /*+ FIRST_ROWS */ EVENT_DATA.info from EVENT_DATA, AGENTS where EVENT_DATA.agent_id = agents.id AND agents.entity IN (163);
    SQL 3 takes a long time to run. The field AGENT_ID is indexed in EVENT_DATA.
    select /*+ FIRST_ROWS */ EVENT_DATA.info from EVENT_DATA, AGENTS where EVENT_DATA.agent_id = agents.id AND agents.entity IN (SELECT /*+ FIRST_ROWS */ entity_group.entity FROM auth, entity_group, user_group WHERE entity_group.auth_group = user_group.groupid and user_group.userid = auth.id and auth.username = 'ing');
    Any suggestions on improving the SQL statement or finding out if anything is wrong with the database.
    Thanks
    Ravi

    First, lose the hints, analyse your tables and let the CBO do its job. If it is not fast enough. then Nicolas' solution may be faster.
    Another possible construct would be:
    SELECT event_data.info
    FROM event_data, agents,
         (SELECT DISTINCT entity_group.entity
          FROM auth, entity_group, user_group
          WHERE entity_group.auth_group = user_group.groupid and
                user_group.userid = auth.id and
                auth.username = 'ing') eg
    WHERE event_data.agent_id = agents.id and
          agents.entity = eg.entityTTFN
    John

Maybe you are looking for

  • System Error message when trying to open Log; noki...

    Hello everybody.  I have a strange problem with a Log on my nokia 6120c. When I try to access the Log from the menu, I get a simple message: "System error" and when I press green button (on the home screen) to quick access dialed numebrs nothing happ

  • Please help me. I'm losing my mind.

    Hello. I just recently bought an Ipod nano and I'm trying to install Itunes into my computer for the first time. I keep getting an error message saying "The folder path "Program Files" contains and invalid character". Please please help me I've tried

  • Shared Review History

    In Acrobat 9, is there a way to clear the shared review history?

  • Java Library to drop the incoming packet flow

    hi there, i m planning to make application layer filter. i need to drop the flow of incoming packets. So can anyone suggest me any java library which is able do this? or else if i have to create my own library then how can i proceed in that?

  • ECC 5.0 database instance install error in  database load (post processing)

    HI  all! The installation of the environment : VM SERVER v1.03 ECC 5.0 /WINDOWS SERVER 2003 SQL SERVER 2000 SP3 DB INSTANCE install occur error in database load (post processing)  step: sapinst.log: INFO 2008-10-16 14:20:54 Creating file C:\Program F