Complex IF statement

Trying to condition one of my detail lines with this IF statment:
<?if:(COUNT_SHIPMENTS != 1 and POH_PO_TYPE != ‘BLANKET’) or (POH_PO_TYPE = ‘RELEASE’ and POH_RELEASE_TYPE = ‘BLANKET’ or xdofx:upper(PLL_SHIP_ADDRESS_LINE1) != xdofx:upper(POH_SHIP_ADDRESS_LINE1) or xdofx:upper(PLL_SHIP_ADR_INFO) != xdofx:upper(POH_SHIP_ADR_INFO) or xdofx:upper(PLL_SHIP_COUNTRY) != xdofx:upper(POH_SHIP_COUNTRY)?>
I'm getting this error ... "Namespace prefix 'xdofx' used but not declared."
Is this because I'm mixing XSL with xdofx? And if so, how would I do an "upper" function in XSL?
Paul

Hi,
You need to use xpath syntax to access the header information. Think of it as being like a directory on your pc. If you are in:
/header/invoice/lines/distributions
and you look list the files you will only see the data that is in that directory. Similarly with xml if you are in a for-each loop at the distribution level you cannot look backwards without some additional syntax.
You will have to work out how many levels you need to go back but the syntax is:
<?../ELEMENT?> to go back one level
<?../../../ELEMENT?> to go back 3 levels
The xpath explanation in the user guide isn't fantastic (unless it's been updated recently). If you want to learn more I would recommend 'Learning XML' published by O'Reilly. It gives a good overview and explanation including the functions such as translate, substring etc.
Thanks
Paul

Similar Messages

  • Issue for running complex insert statement

    Hello expert,
    I have a complex insert statement in store procedure. when I run this statement in toad, it takes only 1 minute. but when I monitor execution of this procedure, it takes about 2 hours. this insert statement is as " insert into table select......". can you tell me the possible reason for that ? by the way , index for these two running are always existing there.
    Many Thanks,

    Thanks for all you reply, I create another procedure using statements from issue procedure. it takes 3 minutes compared with 2 hours for this insert statement in the issue procedure. I find out a statement before this insert statement in the issue procedure as follows, I wonder if this is the reason for low performance:
    EXECUTE IMMEDIATE 'ALTER SESSION SET OPTIMIZER_MODE=RULE';
    at the end of the issue procedure, having another statement:
    EXECUTE IMMEDIATE 'ALTER SESSION SET OPTIMIZER_MODE=ALL_ROWS';
    please tell me if these statement will affect the performance. I know little about DBA, so I post it overhere without advanced investigation. Appreciate very much for your help.

  • Re-doing complex Merge statement in OWB

    I have a complex merge written in sql that needs to be redone in owb.
    The code is something like this :
    MERGE INTO table_1
    USING (
    WITH u1 AS (SELECT STATEMENT 1....)),
    u2 AS (SELECT STATEMENT 2....)),
    u3 AS (SELECT STATEMENT 3....)),
    u4 AS (SELECT STATEMENT 4....)),
    u5 AS (SELECT STATEMENT 5....))
    SELECT *
    FROM (SELECT * FROM u1
    UNION
    SELECT * FROM u2
    UNION
    SELECT * FROM u3
    UNION
    SELECT * FROM u4
    UNION
    SELECT * FROM u5) a,b
    WHERE a.column1 = b.column1(+) ) table_2
    ON (table_1.id = table_2.id)
    when matched then update set....
    when not matched then insert...
    How do I implement some thing like above in OWB? Do i need to use pluggable mappings?
    any feedback would be of great help!
    Thanks
    Billu

    Hi Billu,
    no, you do not need pluggable mappings.
    Design your selects for u1 - u5 as required in one mapping. Then use a set operator (union) with 5 ingroups. Connect the results of your selects to each ingroup.
    Connect the output of the set operator to your target table table_1. Set loading type to insert/update (this will generate a merge statement). Use the column id for matching.
    Regards,
    Carsten.

  • Complex View State handling

    Hi,
    I am trying to solve the following problem in Flex3:
    I have layout with 4 quadrants ["Ch" for Child component
    class]:
    Ch1 Ch2
    Ch3 Ch4
    If I click a button in ch4 [i.e. state ch4a], it is supposed
    to expand and cover Ch2, i.e.
    Ch1
    Ch4a
    Ch3
    Class Parent1 [inside Accordion]:
    VBox
    HBox1
    <view:Ch1 width="60%" />
    <view:Ch2 width="40%" />
    /HBox1
    HBox2
    <view:Ch3 width="60%" />
    <view:Ch4/>
    /HBox2
    /VBox
    So in class Ch4 I created a view stateA which is based on
    BaseState.
    A) What makes more sense, fire event in class Ch4 on that
    button click,
    capture it in Parent1 and somehow [how?] change a layout so
    that Ch2 is not there
    but twice higher Ch4a is instead of it and no second part in
    HBox2 ?
    I would guess, ActionScript instead of MXML or is there a way
    to express that in MXML?
    Or how should that ActionScript look like ?
    B) The other [easier] possibility is to get a handle to
    Parent1 [parent container]
    from the viewstateA of Ch4 and do something like:
    <SetProperty target={this.parent} name="y" value="0">
    Is it feasible? So far that didn't work for me. Any
    suggestions?
    Few other details:
    1) it's all in Cairngorm AIR app;
    2) that button in Ch4 is on one side a toggle button between
    view states,
    on the other side processing is completely different, but I
    can handle that through calling
    2 different private functions. I am saying only in one
    state[BaseState] that event should be fired.
    3) Background: Ch1 and Ch3 have lots of dropdowns, and what
    user selected would be displayed
    in Ch4A [that top portion], so user "Signs" that info, that's
    a point of the whole screen.
    Is there easy way to pass these selections to Ch4 ?
    As of now, it's all buried deep inside some complex obscure
    VOs .
    Any help is very appreciated.
    Thank you in advance,
    Oleg.

    The robot method is quite slow, and it can only capture images that are actually on the screen in the foreground. In any case, I stumbled on this article: [Performance Improvement Techniques for JavaFX Applications|http://javafx.com/docs/articles/performance/] that mentions the 'cache' member variable of a Node/Group can be used to tell the system to convert the Node to a bitmap (internally) for performance improvement. I haven't done any testing of my own, but it's an easy addition if you have a performance sensitive app.

  • Complex if statement in rtf template?

    Hello,
    I want to build an if statement in rtf template, the idea is like:
    <?if:address!='' and phone!=''?>
    <?end if?>
    what's the correct way to do it if it is possible? Thanks in advance!
    Shichao

    stevencallan wrote:
    Conditional statements, in the user guide or the report developer guide, depending on the version you use.
    Page 7-62 in the 10.1.3.2 user guide:
    Use an if statement to define a simple condition; for example, if a data field is a specific value.
    1. Insert the following syntax to designate the beginning of the conditional area.
    <?if:condition?>
    2. Insert the following syntax at the end of the conditional area: <?end if?>.
    For example, to set up the Payables Invoice Register to display invoices only when the Supplier name is "Company A", insert the syntax <?if:VENDOR_NAME='COMPANYA'?> before the Supplier field on the template.
    Enter the <?end if?> tag after the invoices table.Thanks for the reply. But what about two conditions in one if statement? That was my question. :)
    Shichao

  • Need Help: Complex SQL statement

    select segment3, 0 "Other Income"
         , 0 "Sales of Services"
         , 0 "Personnel Costs"
         , 0 "Other Staff Cost"
         , 0 "General Admin"
         , 0 "Travel"
         , 0 "Collaborator"
         , 0 "Training"
         , 0 "Capital"     
         , nvl(round(sum (nvl(PERIOD_ACTIVITY_A,0) + nvl(PERIOD_ACTIVITY_E,0) + nvl(PRDOPEN_A,0) + nvl(PRDOPEN_E,0)),0),0) "Overhead"
         , 0 "Finance Charges"
         from PAYMAN.SNP_OP_DETAIL@OFA
         where segment3= x.new_cc and period_name = p_period
         and segment2 in (select acc_t from CRP_REPORT_ACCT_DETAIL_T where group_id = 10)
         group by segment3
    Please I don't understand select segment3, 0 "Other Income"....there's no column called 0, what is the 0s doing in the select statement?
    Secondly, I don't understand from PAYMAN.SNP_OP_DETAIL@OFA

    Hi,
    OlaTunde wrote:
    select segment3, 0 "Other Income"
         , 0 "Sales of Services"
         , 0 "Personnel Costs"
         , 0 "Other Staff Cost"
         , 0 "General Admin"
         , 0 "Travel"
         , 0 "Collaborator"
         , 0 "Training"
         , 0 "Capital"     
         , nvl(round(sum (nvl(PERIOD_ACTIVITY_A,0) + nvl(PERIOD_ACTIVITY_E,0) + nvl(PRDOPEN_A,0) + nvl(PRDOPEN_E,0)),0),0) "Overhead"
         , 0 "Finance Charges"
         from PAYMAN.SNP_OP_DETAIL@OFA
         where segment3= x.new_cc and period_name = p_period
         and segment2 in (select acc_t from CRP_REPORT_ACCT_DETAIL_T where group_id = 10)
         group by segment3
    Please I don't understand select segment3, 0 "Other Income"....there's no column called 0, what is the 0s doing in the select statement?Columns are one of the expressions that can be in a SELECT clause. There are many other kinds of expressions, including liteals (as in this example), pseudo-columns, functions, and compound expressions that are also allowed.
    Consider the following query:
    SELECT       deptno          AS raw_detpno
    ,       1 + deptno          AS one_plus
    ,       0 + deptno          AS zero_plus
    ,       0                  AS zero
    FROM       scott.dept
    ORDER BY  deptno
    ;Output:
    RAW_DETPNO   ONE_PLUS  ZERO_PLUS       ZERO
            10         11         10          0
            20         21         20          0
            30         31         30          0
            40         41         40          0No doubt you're familiar with using table columns (such as deptno) by themselves as an expression, as in the output column raw_deptno.
    You're probably familiar with using a table column and a numeric literal together, as in the ouptuput columns one_plus and zero_plus.
    It's also allowed to use numeric literals by themselves, as in the output column called zero.
    Expressions are part of the SQL language, so you can read about them in the SQL language manual:
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/expressions001.htm#sthref1844
    Secondly, I don't understand from PAYMAN.SNP_OP_DETAIL@OFA@OFA is a database link. See
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/queries010.htm#sthref2287

  • Sql complex join statements

    I have been seraching for reference material that show
    an illustration of ER Diagrams and SQL join statements.
    I am usually developing queries from looking at an ER diagram and no other documentation. The books I am finding only have simple easy SQL join examples. I can no find a book that shows difficult join queries or relate join queries with ER diagrams. I am stuck in one case
    where I have a table that relates to two other tables but there is a third table in common with both of them.
    How should this join statement look?
    Sometime I code the join logic correct but the parentheses
    are in the wrong place. Can you help on this one as well?

    NLV, 
    Is this still an issue?
    If so, please read Visakh16's last
    response. We need more information.
    [Personal Site] [Blog] [Facebook]

  • RE: complex Oracle Decode Statement

    I have one complex Decode statement that i can not able to understand it.
    in the parameter it contains--> 1142009 <- as mmqyyyy formate.
    Below is the code.
    to_char(decode(substr('1142009',4,4),(to_char(sysdate,'yyyy')-2),
    decode(substr('1142009',0,2),0,
    decode(substr('1142009',3,1),0,12,
    5,12,
    1,03,
    2,06,
    3,09,
    4,12,substr('1142009',0,2)),substr('1142009',0,2)),
    decode(substr('1142009',4,4),(to_char(sysdate,'yyyy')-1),
    decode(substr('1142009',0,2),0,
    decode(substr('1142009',3,1),0,12,
    5,12,
    1,03,
    2,06,
    3,09,
    4,12,substr('1142009',0,2)),substr('1142009',0,2)),
    decode(substr('1142009',4,4),to_char(sysdate,'yyyy'),
    decode(substr('1142009',0,2),0,
    decode(substr('1142009',3,1),0,(to_char(r.reporting_date,'mm')-1),
    5,to_char(r.reporting_date,'mm'),
    1,03,
    2,06,
    3,09,
    4,12,to_char(r.reporting_date,'mm')),substr('1142009',0,2))
    ,substr('1142009',0,2)))),'00') = pw.month_number
    Any kind of suggestion welcome.
    Thanks.

    Hi,
    Create in a Oracle database in any schema a test table:
    ============================================
      CREATE TABLE  "TEST"
       (     "REPORTING_DATE" DATE,
         "MONTH_NUMBER" NUMBER
    REM INSERTING into TEST something more meaningfull:
    ============================================
    Insert into TEST (REPORTING_DATE,MONTH_NUMBER) values (to_date('12.12.09','DD.MM.RR'),12);
    Insert into TEST (REPORTING_DATE,MONTH_NUMBER) values (to_date('07.08.99','DD.MM.RR'),9);
    COMMIT;
    Test the Query:
    =============
    select to_char( decode( substr( '1142009', 4, 4 ), (to_char (sysdate,'yyyy') - 2),
                 decode( substr( '1142009', 0, 2 ), 0                                       ,
                 decode( substr(' 1142009', 3, 1 ), 0                                       ,12,5,12,1,03,2,06,
    3,09,
    4,12,substr('1142009',0,2)),substr('1142009',0,2)),
    decode(substr('1142009',4,4),(to_char(sysdate,'yyyy')-1),
    decode(substr('1142009',0,2),0,
    decode(substr('1142009',3,1),0,12,
    5,12,
    1,03,
    2,06,
    3,09,
    4,12,substr('1142009',0,2)),substr('1142009',0,2)),
    decode(substr('1142009',4,4),to_char(sysdate,'yyyy'),
    decode(substr('1142009',0,2),0,
    decode(substr('1142009',3,1),0,(to_char(r.reporting_date,'mm')-1),
    5,to_char(r.reporting_date,'mm'),
    1,03,
    2,06,
    3,09,
    4,12,to_char(r.reporting_date,'mm')),substr('1142009',0,2))
    ,substr('1142009',0,2)))),'00')
    from test r
    Damm the writer of the code
    ======================
    It will not be possible to reeningeer or analyse this
    ... Use oracle SQL Developer
    =======================
    Good Luck
    ========
    Martin

  • What is the best practice for changing view states?

    I have a component with two Pie Charts that display
    percentages at two specific dates (think start and end values).
    But, I have three views: Start Value only, End Value only, or show
    Both. I am using a ToggleButtonBar to control the display. What is
    the best practice for changing this kind of view state? Right now
    (since this code was inherited), the view states are changed in an
    ActionScript function which sets the visible and includeInLayout
    properties on each Pie Chart based on the selectedIndex of the
    ToggleButtonBar, but, this just doesn't seem like the best way to
    do this - not very dynamic. I'd like to be able to change the state
    based on the name of the selectedItem, in case the order of the
    ToggleButtons changes, and since I am storing the name of the
    selectedItem for future reference.
    Would using States be better? If so, what would be the best
    way to implement this?
    Thanks.

    I would stick with non-states, as I have always heard that
    states are more for smaller components that need to change under
    certain conditions, like a login screen that changes if the user
    needs to register.
    That said, if the UI of what you are dealing with is not
    overly complex, and if it will not become overly complex, maybe
    states is the way to go.
    Looking at your code, I don't think you'll save much in terms
    of lines of code.

  • Statement vs PreparedStatements which is better in which situation

    Hi i read in a few forums and a few articles that PreparedStatement object performs better than the Statement object in situations where a high number of the same sqls are used because it precompiles the sql statement. such as inserting a 1000 employees into a table.
    i did the following test and found that the gain for using PreparedStatements is sometimes not a gain but a loss.
    What the test basically does is that it inserts an item into the table a 2000 times using both PreparedStatements and Statement objects. And it switches between which object it uses to insert item into the table. So in the end 1000 items would have been inserted using PreparedStatements and 1000 using Statement objects.
    Am i doing somthing wrong with my test or is the so called gain by using PreparedStatements a fluke. Please advise.
    import java.sql.*;
    public class TEST {
        static int Prepcount = 1;
        static long PreptotalTime = 0;
        static long PrepstartTime = 0;
        static long PrependTime = 0;
        static long Prepavarage = 0;
        static int Stmtcount = 1;
        static long StmttotalTime = 0;
        static long StmtstartTime = 0;
        static long StmtendTime = 0;
        static long Stmtavarage = 0;
        static PreparedStatement pst;
        static Statement stmt;
        static ResultSet rs;
        static Connection conn;
        public static void usePrep() {
            try {
                pst = conn.prepareStatement("insert into Dhanu values (?,?)");
                PrepstartTime = System.currentTimeMillis();
                pst.setInt(1, Prepcount);
                pst.setInt(2, Prepcount);
                pst.executeQuery();
                PrependTime = System.currentTimeMillis();
                PreptotalTime = PreptotalTime + (PrependTime - PrepstartTime);
                Prepavarage = PreptotalTime / Prepcount;
                Prepcount++;
                pst.close();
            } catch (Exception e) {
                e.printStackTrace();
        public static void useStatement() {
            try {
                StmtstartTime = System.currentTimeMillis();
                stmt = conn.createStatement();
                rs = stmt.executeQuery("insert into Dhanu values ("+Stmtcount+","+Stmtcount+")");
                StmtendTime = System.currentTimeMillis();
                StmttotalTime = StmttotalTime + (StmtendTime - StmtstartTime);
                Stmtavarage = StmttotalTime / Stmtcount;
                Stmtcount++;
                rs.close();
                stmt.close();
            } catch (Exception e) {
                e.printStackTrace();
        public static void main(String[] args) {
            try {
                Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
                conn = DriverManager.getConnection("jdbc:oracle:thin:@XXX.XXX.XXX.XXX:1521:XXX", "XXX", "XXX");
                System.out.println("Connected to DB");
                conn.setAutoCommit(true);
                for(int x=1;x<=2000;x++){
                    if(x%100==0){
                       System.out.println("Count is "+x);
                    if(x%2==0){
                        usePrep();
                    }else
                        useStatement();
                System.out.println("Prepcount " + Prepcount + " Prepavarage " + Prepavarage + " CurrentExecution " +(PrependTime - PrepstartTime)+ " Totaltime "+PreptotalTime);
                System.out.println("Stmtcount " + Stmtcount + " Stmtavarage " + Stmtavarage+ " CurrentExecution " +(StmtendTime - StmtstartTime)+ " Totaltime "+StmttotalTime);
                System.err.println("Statement time - Prep Time " + (StmttotalTime - PreptotalTime ));
            } catch (Exception ex) {
                ex.printStackTrace();
                System.exit(0);
    }

    sjasja wrote:
    There can still be a performance advantage to PS's even when not used in a loop. Oracle in particular has a textual statement cache. When you execute
    insert into foo values(1);
    insert into foo values(2);
    insert into foo values(3);
    the three statements are textually different, so they get re-parsed and the query optimizer runs thrice. But when you prepare
    insert into foo values(?);
    the parsed and optimized statement remains in the statement cache for some time, and each execution with a different value for "?" can use the pre-parsed statement. The more complex the statement, the bigger the advantage.Yes they do, and so do many others. But it is only that, a cache. It will "usually" be available, not necessarily always. But, in any case, it is still best practice to prepare it, use it multiple times, and close it.
    >
    I have heard rumors of databases (MSSQL???) where a PS is indeed costlier, as the protocol between the JDBC driver and the DB server requires a separate compilation step. One could argue that in this world, where Java is so important in the server side, and the other advantages of PreparedStatement favor its use, any serious database has had much reason in the last decade to implement a protocol where a separate compilation step is not needed, and any other speed penalties for PSs are decidedly not a marketing advantage.One could argue that, and many have, but PreparedStatements did not spring into being with JDBC, they have existed previously. They are easier to use, however, in Java, and some sort or precompilation is required (even if it is only done the first time the statement is actually run) because at some point in time the DB must determine the paths to take when actually executing the statement, and that was the purpose behind precompiled statements in the first place, so that that determination is done once, and used multiple times. Otherwise it is done as the statement is executed, each time a statement is executed (unless, at least in Oracle, the same statement is still in the statement cache, then it is also reused, rather than redetermined).

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

  • Error in CASE statement used in Reports query

    My query has lots of selection criteria. I'm trying to use CASE for that.
    This is a part of my query with parameters:
    AND ad.location IN (CASE &p_location
    WHEN 1 THEN
    (SELECT TRIM(code_nbr) FROM code_detail
    WHERE code_nbr like 'LC%')
    WHEN 2 THEN -- then the user can type in more than 1 locations
    &p_location1|| p_location2
    END)
    AND --- there are more conditions after this
    The query fails that invalid relational operator in this CASE statement.
    Any suggestions...is there any other way to do it...Thanks in advance

    I would recommend the use of lexical parameters in the before report trigger
    Set up a parameter SQL_WHERE - text, 4000 chars.
    In your datamodel get rid of the case statement and just put &SQL_WHERE
    In the before report trigger modify your case statement to be something like:
    &SQL_WHERE:=' and ad.location in ';
    case when :p_location = 1 then
    &SQL_WHERE:=&SQL_WHERE||' select trim(code_nbr) from code_detail etc';
    end
    This way you can debug and test your case statement in the pl/sql environment. Plus the query should run faster as you are moving the complex where statement into a separate part of the report

  • HINTS in Select Statement

    Hi,
    Can anybody explain me why HITS keyword is used with SELECT statement, whats the use of if, How to find the HINTS for a particular table.
    SELECT recn, recnroot, ippers
    INTO CORRESPONDING FIELDS OF TABLE <ITAB1>
    FROM CCIHT_IP
    FOR ALL ENTRIES IN <ITAB2>
    WHERE ippers = <ITAB2>-ippers
    AND valfr LE sy-datum
    AND valto GE sy-datum
    AND iptype = 'INJ'
    %_hints db2 '&max_blocking_factor 500&&max_in_blocking_factor 500&u2019.
    -Rajiv

    Hi,
    Complex database statements or large numbers of secondary indexes that can be very
    similar make it difficult for the database optimizer and the R/3 database interface to process
    most efficiently. In some database systems, you can expressly influence decisions made by
    database optimizer by what are known as hints.
    Ex- %_HINTS ORACLE '&SUBSTITUTE VALUES&'.
    Search with HINTS in SELECT STATEMENT you will get so many ans

  • Performance of SQL-Statements in Reports

    Hi
    I have a very complex SQL-Statement in a Region-Report with Items in the where-clause:
    select ....
    where  idt_1 like :P1_IDT
    and    idt_2 like :P1_IDT2
    ...it generates 100 Million records in the Temp Tablespace and produce either a timeout or an error-message that the Temp-Tablespace is not big enough.
    If I replace the Items with real values it runs in a few seconds in the SQL-Workshop.
    select ....
    where  idt_1 like 10
    and    idt_2 like 11
    ...If I use the Region-Type based "PL/SQL Function Body returning SQL Statement" and generate the Statment like this:
    v_statment:= 'select ... where idt_1 like ' || :P1_IDT;
    return v_statment;it runs in a few seconds too.
    Any explanations?
    Regards, Juergen

    Jürgen,
    John's recommendation is sound. Your last two examples ultimately use literal values in your query statement (that is, the query optimizer can use these values to determine the optimal query plan). The query plans for the last two queries may be entirely different than what was generated for your first query.
    Additionally, if the selectivity of your first query shifted dramatically across subsequent executions, the query plan initially generated may not be suitable again.
    Examining the tkprof output should elucidate all of this.
    Joel

  • XPATH statement help

    I'm trying to write a little learning game in Flash, using
    XML as the data source, but I can't get any XPATH statements to
    work. I've written tons of XPATH against this structure in
    JavaScript, and the XPATH statements evaluate properly in XML Spy,
    but I always get "undefined" when I try to trace out the value of
    the XPATH statements in Flash 8.
    I'll post a valid (to XML Spy, that is) XPATH statement and
    some sample code...
    Thanks much for any help!
    Mike

    Okay, I'm experimenting now, I'll post if I figure out
    anything useful. Although I admit, I'm not going to waste a lot of
    time on this, if it looks like it's going to be overly difficult
    (which it appears at this point it will be) given the limited
    implementation, I'm just going to port the game to DHTML/Javascript
    and use a decent XPATH implementation. I have probably 10 or more
    relatively complex XPATH statements that I want to use, similiar in
    logic to:
    get all <theText> nodes whose parent <question>
    node has a learningWheelUsage attribute set to "yes".
    This is really simple in every other environment that I work
    in, and I'm thinking it would just be easier to port the game to
    something else than try to hack together a solution out of Flash's
    limited implementation.
    I'd want to put those into an array of course.. I haven't
    given up hope yet, I'm going to do some more experimenting, but it
    is FRUSTERATING!!!!! hahaha..
    Thanks for the help!
    Mike

Maybe you are looking for

  • Xcelsius - LiveOffice: Unable to refresh SWF File - LO 26608

    Hello, i have a problem updating crystal report data using the refresh button in the preview tab of Xcelsius. Both files (Crystal Report and Xcelsius File) are stored on the BOE Server and i configured two Live Office Connections from Xcelsius to Cry

  • Ipod 4th gen.Wont turn on.

    My ipod touch 4th generation took water damage from a small cup of water. As soon as the water had contact with the ipod i dried it out and turned the ipod off. Now it will not turn on. Iconnect it to the charger or pc and it will show the black scre

  • 'Format Payment Instructions with Text Output' program ending in error

    Hi All, 'Format Payment Instructions with Text Output' program of the payment cycle is completing in to error. error is: length of the output - baos::4914 After formatting, periodicSeq is null or empty.{} length of the output - baos::4914 Exit: iby.s

  • JDBC : error in receiver communication channel?

    Hi Experts , I am doing a JDBC to JDBC scenario. The following error comes in my receiver communication channel monitoring. Error while parsing or executing XML-SQL document: Error processing request in sax parser: Error when executing statement for

  • Function Modules for Payroll

    Hi SAP Minds, Please provide the answers for the following and guide me  to learn Payroll technically.. what is offcycle payroll? what are  the Function Modules used to read the data from Offcycle payroll? what are the Function modules used to read R