Query/Looping Problem

I have a database table with columns as follows.
racerID
race1
race2
race3
race4
race5
race30
totalScore
I do my query as follows:
SELECT *
FROM races
WHERE racerID = URLVar
I want so loop through the query results to list the points
by race... my problem is that they are all in one record...
I tried these:
<cfloop index="i" from="1" to ="30">
<p>#races.race#i##</p>
</cfloop>
I also tried using square brackets around i at the end of
races.race...
How can i reverence a field name using i?
All help is appreciated. I have had this problem on more than
one site i have done and i have always just broke down and typed
all the code out for each field, but there has to be an easier
way.

Just from what you have listed, this seems to be a bad data
model design. What happens if you add another race? You would have
to add another column to your table. You might consider having a
racer table, with all of the attributes associated with a racer, a
race table with all of the attributes associated with a race, then
an "associative entity" (link table) to link race with racer. This
race_racer table would have the ID for the racer, and the ID for a
given race, and the points for that race and racer so that you
could find race info for any particular racer of race by joining
these tables. Then it would be a snap to list the points by race or
racer using SQL and not having to use outside loops, etc. In other
words, normalize your data.
<edit> looks like Dan beat me to it </edit>
Phil

Similar Messages

  • About query related problem

    hi ,
           we are generate query in 2005b,and procced for execuite query.following problem occure'<b>odbc sql server driver'[sql server] syntax error the converting the nvarchar value' 70302/20307' to column of data type int received alert OAIB</b>
    QUERY SHOWN BE AS FOLLOW.
    SELECT T5.DocNum as'Po. No. ', T5.DocDate as 'Po Date',T0.CreateDate,T5.NumAtCard as 'Man.PO. No/ Dt.', T0.DocNum as'AP No. ', T0.DocDate as 'AP Date',T0.NumAtCard as 'Vendor Ref. No.', T0.U_vbdt as 'Vendor Ref. Date', T0.CardName as 'Vendor', T1.Dscription as 'Item',  T1.Quantity AS 'QTY'  , T1.Price as 'Basic Rate', (T1.Price *T1.Quantity) as 'Value',T0.Comments as 'Po No. & Po.Dt.' FROM OPCH T0 INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode INNER JOIN OPDN T3 ON T2.CardCode = T3.CardCode INNER JOIN PDN1 T4 ON T3.DocEntry = T4.DocEntry INNER JOIN OPOR T5 ON T2.CardCode = T5.CardCode INNER JOIN POR1 T6 ON T5.DocEntry = T6.DocEntry INNER JOIN OITM T7 ON T1.ItemCode = T7.ItemCode INNER JOIN OITB T8 ON T7.ItmsGrpCod = T8.ItmsGrpCod WHERE (  T1.BaseRef  =  T3.DocNum )  AND ( T4.BaseRef =  T5.DocNum ) AND (  T0.U_vbdt >=[%25]AND  T0.U_vbdt <=[%26]) AND ( T4.Dscription =T1.Dscription ) AND ( T4.Dscription = T6.Dscription  ) AND  (( T1.Dscription=[%0] OR T1.Dscription=[%1] OR T1.Dscription=[%2] OR T1.Dscription=[%3] OR T1.Dscription=[%4] OR T1.Dscription=[%5] OR T1.Dscription=[%6] OR T1.Dscription=[%7] OR T1.Dscription=[%8] ) OR ( T0.CardName=[%10] OR T0.CardName=[%09] OR T0.CardName=[%27] OR T0.CardName=[%28] ) OR ((  T8.ItmsGrpNam =[%11]  oR T8.ItmsGrpNam =[%12] OR T8.ItmsGrpNam =[%13] OR T8.ItmsGrpNam =[%14] OR T8.ItmsGrpNam =[%15] OR T8.ItmsGrpNam =[%16] OR T8.ItmsGrpNam =[%17] OR T8.ItmsGrpNam =[%18] OR T8.ItmsGrpNam =[%19] ) and  ( T7.U_FirmName =[%20] OR T7.U_FirmName =[%21] OR T7.U_FirmName =[%22] 
    oR T7.U_FirmName =[%23] OR T7.U_FirmName =[%24] )) )

    Hi Vishal,
    the value '70302/20307' is not an whole number so converting it to an int is not possible.
    You should check your data for this value an change your query or data.
    Regards
    Ad

  • Query designing problem while applying cell properties

    Hello Experts,
    I have a problem while designing query. Problem is as follow:
    I have a calculated field on key figure column. This key figure calculates variance between 2 columns.
    for E.g I have 2 columns Budget and Actual and third column is %Variance which should be          
    1. ((Actual - Budget)/Budget) *100 or
    2. ((Budget -Actual)/Budget)*100, depening on some values on the row i should use any of these 2 formulas but the result should be dispalyed in single column % Variance.
    how can i change the formula in key figures depending on these conditions. I can achieve this by applying cells but i dont want to do so as it is very complex way to desing these queries.
    also let me know applying cells on query affects its performance or not?
    Regards,
    Nirav

    Hi Nitin,
    Your reply may help me.
    But my exact requirement is not that. Requirement is as follow:
    I have created Char. Structure in row which contains few rows as revenue and few rows as expense.
    I created them by creating selections. Now in case of expense the variance should be                (Budget-Actual)/Budget *100.
    In case of revenue variance should be (Actual-Budget)/Budget *100.
    So, here i have to find out revenue & expense char. iresspective of which one is greater.
    Regards,
    Nirav

  • Query has problem

    Below query has problem .
    Pls see the queries for Usage Summary with Partition and Without Partition
    . I have executed this now so it may be in Buffer …****
    DB Query ... SUM from event objects, bin variables
    SELECT sum(amount) , sum(quantity), event.poid_type,ebal.resource_id,****
    event.service_obj_type, event.service_obj_id0,ebal.
    rate_obj_id0, ebal.OFFERING_OBJ_ID0, ebal.IMPACT_CATEGORY ****
    FROM event_bal_impacts_t ebal, item_t item, event_tevent*
    WHERE event.item_obj_id0 = item.poid_id0****
    AND ebal.obj_id0 = event.poid_id0****
    --                   and event.Poid_id0 >= 266838277921701888****
    --                 and event.Poid_id0 < 267928993456455680****
    --               and ebal.obj_id0 >= 266838277921701888****
    --             and ebal.obj_id0 < 267928993456455680****
    AND item.bill_obj_id0 = 148715294****
    AND ebal.product_obj_id0 = 27433706****
    AND ebal.account_obj_id0 = 146876519****
    AND item.account_obj_id0 = 146876519****
    AND event.poid_type like '%session/telco/gsm%'****
    AND ebal.impact_category <> 'Free'****
    AND resource_id not in (select resource_id from
    resource_id_t)****
    group by****
    event.poid_type, ebal.resource_id,****
    event.service_obj_type, event.service_obj_id0,****
    ebal.rate_obj_id0, ebal.OFFERING_OBJ_ID0,ebal.
    IMPACT_CATEGORY****
    order by****
    ebal.resource_id desc;****
    SELECT sum(amount) , sum(quantity), event.poid_type,ebal.
    resource_id,****
    event.service_obj_type, event.service_obj_id0,ebal.
    rate_obj_id0, ebal.OFFERING_OBJ_ID0, ebal.IMPACT_CATEGORY ****
    FROM event_bal_impacts_t ebal, item_t item, event_tevent*
    WHERE event.item_obj_id0 = item.poid_id0****
    AND ebal.obj_id0 = event.poid_id0****
    and event.Poid_id0 >= 264199450015039488****
    and event.Poid_id0 < 265237388991660032****
    and ebal.obj_id0 >= 264199450015039488****
    and ebal.obj_id0 < 265237388991660032****
    AND item.bill_obj_id0 = 148715294****
    AND ebal.product_obj_id0 = 27433706****
    AND ebal.account_obj_id0 = 146876519****
    AND item.account_obj_id0 = 146876519****
    AND event.poid_type like '%session/telco/gsm%'****
    AND ebal.impact_category <> 'Free'****
    AND resource_id not in (select resource_id from
    resource_id_t)****
    group by****
    event.poid_type, ebal.resource_id,****
    event.service_obj_type, event.service_obj_id0,****
    ebal.rate_obj_id0, ebal.OFFERING_OBJ_ID0,ebal.
    IMPACT_CATEGORY****
    order by****
    ebal.resource_id desc;****
    --

    848478 wrote:
    Below query has problem .
    Pls see the queries for Usage Summary with Partition and Without Partition
    . I have executed this now so it may be in Buffer …****
    DB Query ... SUM from event objects, bin variables
    SELECT sum(amount) , sum(quantity), event.poid_type,ebal.resource_id,****
    event.service_obj_type, event.service_obj_id0,ebal.
    rate_obj_id0, ebal.OFFERING_OBJ_ID0, ebal.IMPACT_CATEGORY ****
    FROM event_bal_impacts_t ebal, item_t item, event_tevent*
    WHERE event.item_obj_id0 = item.poid_id0****
    AND ebal.obj_id0 = event.poid_id0****
    --                   and event.Poid_id0 >= 266838277921701888****
    --                 and event.Poid_id0 < 267928993456455680****
    --               and ebal.obj_id0 >= 266838277921701888****
    --             and ebal.obj_id0 < 267928993456455680****
    AND item.bill_obj_id0 = 148715294****
    AND ebal.product_obj_id0 = 27433706****
    AND ebal.account_obj_id0 = 146876519****
    AND item.account_obj_id0 = 146876519****
    AND event.poid_type like '%session/telco/gsm%'****
    AND ebal.impact_category <> 'Free'****
    AND resource_id not in (select resource_id from
    resource_id_t)****
    group by****
    event.poid_type, ebal.resource_id,****
    event.service_obj_type, event.service_obj_id0,****
    ebal.rate_obj_id0, ebal.OFFERING_OBJ_ID0,ebal.
    IMPACT_CATEGORY****
    order by****
    ebal.resource_id desc;****
    SELECT sum(amount) , sum(quantity), event.poid_type,ebal.
    resource_id,****
    event.service_obj_type, event.service_obj_id0,ebal.
    rate_obj_id0, ebal.OFFERING_OBJ_ID0, ebal.IMPACT_CATEGORY ****
    FROM event_bal_impacts_t ebal, item_t item, event_tevent*
    WHERE event.item_obj_id0 = item.poid_id0****
    AND ebal.obj_id0 = event.poid_id0****
    and event.Poid_id0 >= 264199450015039488****
    and event.Poid_id0 < 265237388991660032****
    and ebal.obj_id0 >= 264199450015039488****
    and ebal.obj_id0 < 265237388991660032****
    AND item.bill_obj_id0 = 148715294****
    AND ebal.product_obj_id0 = 27433706****
    AND ebal.account_obj_id0 = 146876519****
    AND item.account_obj_id0 = 146876519****
    AND event.poid_type like '%session/telco/gsm%'****
    AND ebal.impact_category <> 'Free'****
    AND resource_id not in (select resource_id from
    resource_id_t)****
    group by****
    event.poid_type, ebal.resource_id,****
    event.service_obj_type, event.service_obj_id0,****
    ebal.rate_obj_id0, ebal.OFFERING_OBJ_ID0,ebal.
    IMPACT_CATEGORY****
    order by****
    ebal.resource_id desc;****
    --Consider getting the asterisk key fixed, since it results in invalid SQL syntax

  • Not the usual 'login loop' problem, help.

    The login loop problem I'm facing is not the usual login loop problem when starting up mac; it's when I'm trying to log into websites or applications (most of them, eg. facebook, instagram).
    I have tried:
    using other browsers: Safari, Firefox, Maxthon, Chrome
    clearing all cookies / caches / keychains / passwords
    repairing disk
    deleting launchservices cache
    using other userid to login
    All to no avail.
    How do I solve this without having to reformat/install mac?
    Thank you.

    Hi, are you using Parental contrils or a managed account, or an admin account?
    Using any Anit-Vrus software?

  • Trying SSH CLI ,  reading command line method is infinte loop problem!

    I am trying excute command and reading result. but reading result part has problem.
    below source is a part of my method.
    try{
                   SessionChannelClient sessionChannel = ssh.openSessionChannel();
                   sessionChannel.startShell();
                   OutputStream out = sessionChannel.getOutputStream();
                   String cmd = s + "\n";
                   out.write(cmd.getBytes());
                   out.flush();
                   InputStream in = sessionChannel.getInputStream();
                   BufferedReader br = new BufferedReader(new InputStreamReader(in));
                   byte buffer[] = new byte[255];
                   String read= "";
                   while (true) {
                        String line = br.readLine();
                        if (line == null)
                             break;
                        str += line;
                        str += "\n";
                   System.out.print(str); //print result
                   sessionChannel.close();
                   in.close();
                   out.close();
              }catch(IOException ee){
                   System.out.println(ee);
              }finally{
                   System.out.println("=============end cmd=============");
    while loop has problem. While statement has infinite loop problem.
    why has this problem?
    anybody, help me please. Thanks for reading .
    Edited by: BreathAir on Aug 5, 2008 12:16 AM

    That loop will loop until readLine() returns null, which will only happen when the other end closes its end of the connection, and it will block while no data is available.

  • Nested query loops

    If you have nested query loops (<cfloop
    query="qA"><cfloop query="qB"> qA vars in here
    </cfloop></cfloop>), is it possible to carry the vars
    from qA into the qB loop.
    Not sure if this makes sense, but any time i have nested
    query loops, i can't access the outer loops vars.

    Use a different index variable for each loop. Use complete
    syntax, ie queryname.fieldname[rownumber] for each query
    variable.

  • Failure to search - query window problem

    Hello again,
    Have anyone of you came across a problem with SAP search mechanism in query window attached to document field? I've created a simple query of "Select acctcode,acctname from OACT where acctcode like '2%' and postable='Y' order by acctcode" and attached it to one of document fields (doesn't matter which one). When I run this query a usual window poped up with a search field on the top, but when I typed "2" in it, selection bar moved right into first 231 account ignoring any of the lesser numbers. There is more - when I changed query to search for '5%' like accounts, I gained the same result - accounts less than 530 were ignored even if I typed "50" or "51". BUT - when I changed query sort order to "desc", all account became "findable".
    I got this problem in one database only which is SAP 8.8 PL10 version upgraded recently from 2007A one. I've checked with a newly created 8.8 and such problem hasn't occured.

    Hello Thomasz,
    I might be off base here, what happens when you use this??? 
    Do you get the same types of query window problem???
    Select
    acctcode,
    acctname,
    segment_0
    from OACT
    where Segment_0 like '2%'
    order by acctcode
    for browse
    Regards,
    Zal

  • Sony D-50 "boot-up loop" problem

    I have a Sony D-50 portable recorder barely three months old that did something totally strange. Has anyone else had this problem?
    During a shoot yesterday, I noticed that the Sony D50 I bought back in August would not turn OFF.
    When I moved the power switch to the OFF position, the machine went into a "boot up loop," that is:
    I'd turn it OFF after recording.
    Screen goes black.
    I get the "See you!" message.
    Screen lights up again.
    The word "SONY" appears as though it's gonna boot up,
    Then the whole process starts over again
    Screen goes black.
    I get the "See you!" message.
    Screen lights up.
    The word "SONY" appears as though it's gonna boot up....
    So, same thing late last night.
    I get up this morning and turn it ON; it works fine until I turn it off, then it goes back into the "boot loop" thing again.
    I tried everything I could think of, even searching for a "RESET" on the machine and in the Menu. I finally had to take the batteries out of it to shut it down.
    Then, I did something that apparently---so far---fixed it.
    This is so strange---right out of the Twilight Zone:
    I put the batteries back in it, then it starts the loop again.
    Since it won't turn OFF, I take the batteries out of it in the OFF position. I wait five minutes and put the batteries back in it with it in the OFF position.
    Same problem---the "boot up loop" thing.
    I take the batteries back out of it again in the OFF position and wait fifteen minutes. I put the batteries back in it while it's still in the OFF position. Guess what?
    Problem solved: It's doesn't start the "boot up loop" thing.
    So, I turn it back ON. Machine boots up fine and is ready to record.
    OK, I turn it OFF.
    Back to the exact same problem---It shuts down and goes into the "boot up loop" again.
    I go back through the same process of removing and installing the batteries with the machine in the OFF position.
    Nothing changes.
    Then, I have an idea.
    With the machine in the OFF position and going through the "boot up loop" thing, I remove the batteries.
    I then move the power switch to the ON position before I put the batteries back in it---had not tried that before: reinstalling the batteries with it in the ON position. I install the batteries with the machine in the ON position.
    Machine boots up fine and is ready for recording.
    Now, I turn it OFF.
    The machine shuts down fine with no "boot up loop" problem.
    Putting the batteries back in the machine with it in the ON position instead of the OFF position apparently solved the problem.
    So, I turn it back ON and then OFF several times.
    Same thing: No "boot up loop" problem.
    Do-do-Do-do....
    The machine now works fine.
    Anyone ever had this happen to a Sony D-50?
    I'm wondering if I should send it to back to Sony before it does this again. For God's sake, it's only three months old!
    I bought it after rave reviews in the "recorder" community, and I haven't found anyone else who has had this problem with one..

    Sorry to see that you were having this issue with your PCM-D50 Linear PCM Recorder - if you continue having the issue the unit may need service - give Sony Business and Professional team a call and they will be happy to assist:
    http://pro.sony.com/bbsc/ssr/services.s ... port.shtml

  • Possible solution to "Looping" problem

    Hello all, I've read several threads here dealing with a "looping" problem, I'm not sure what the ins-and-outs of this issue is but it seems to affect many different config and different manufacturers are blaming each other... check out the link below (mind the wrapping) for what might be a real solution at the Via forums. I happened upon this because I could not get a stable system out of my MSI via-km266 mobo with dual display.
    http://forums.viaarena.com/messageview.cfm?catid=25&threadid=9263&highlight_key=y&keyword1=dual%20display
    Alpay Eno

    What is the problem? Let the filters return a List instead of an array. Am I missing something?
    Kaj

  • SAP QUERY LOOPS AND INTERNAL TABLE

    Hi All, I have a query which i have made. It runs from Table EKPO which has PO details and what I want to do is now via ABAP Code pull through the total of goods receipt for the PO and Line Item into a field. Sounds Easy enough..Problem now,
    The table which contains the GR data is EKBE which agains a PO and Line Item can have many 101 movements and 102 movements so what I want is an ABAP Statent to basically sum up the total of 101 for the PO & LINE ITEMS and then minus this from the total of 102 for the PO & LINE ITEMS and post the result in to this new field I have created.
    I am pretty decent with ABAP Code in Querys I.e Select statements etc but from what I can see i need to create an internal table and do a loop and collect statement but I keep on failing due to not enough knowledge. Please can some one help me with this and provide me with the code and explanation as i would like to understand,
    POINTS WILL BE REWARDED
    Thanks
    Kind Regards
    Adeel Sarwar

    Hi,
    This is the full code i have entered but its not working. Any help would be appreciated. If you could rectify the code and internal tables that would be great.
    Thanks
    TABLES: EKBE.
    DATA: PurO LIKE EKPO-EBELN,
          POLI LIKE EKPO-EBELP.
    *New Table and Vars defined
    DATA:   BEGIN OF IT_EKBE,
              IT_EKBE LIKE EKBE,
            END OF IT_EKBE.
    DATA:  BEGIN OF IT_SUM OCCURS 0,
              EBELN TYPE EBELN,
              EBELP TYPE EBELP,
              DMBTR TYPE DMBTR,
              MENGE TYPE MENGE,
          END OF IT_SUM.
    CLEAR: QTYD.
    MOVE: EKPO-EBELN TO PurO,
          EKPO-EBELP TO POLI.
    SELECT * FROM EKBE INTO IT_EKBE
        WHERE EBELN = PurO
        AND   EBELP = POLI
        AND   BEWTP = 'E'
    LOOP AT IT_EKBE.
      MOVE CORRESPOING IT_EKBE TO IT_SUM.
      IF IT_EKBE-BWART = '102'.
        IT_SUM-DMBTR = IT_SUM-DMBTR * -1.
        IT_SUM-MENGE = IT_SUM-MENGE * -1.
      ENIDF.
      COLLECT IT_SUM.
      CLEAR IT_SUM.
    ENDLOOP.
    ENDSELECT.
    If sy-subrc = 0.
      QTYD = IT_SUM.
    ELSE.
      QTYD = 0.
    ENDIF.

  • Query Optimization Problem

    Hi
    I have a optimization problem and wondering if you can help me, The problem is I am getting two diffrent costs for two diffrent users, when I login and run as the object owner the cost is normal but when I login and run the query as a diffrent user I have a dramatic increase in the costs.
    For example to retrieve the rows from Work_Order_Coding_Tab as the object owner the cost is 1 while logged in as the other user the cost is 26070 :(.
    views such as xxx_work_order_coding, active_work_order has got more than 2 million records.
    The query is
    SELECT a.wo_no "AOnr", a.customer_no "Kundnr", c.name "Kundnamn",
    a.contact "Kontakt", a.reference_no "Referens",
    a.err_descr "Kort_beskrivning", replace(a.err_descr_lo, chr(13) ||
    chr(10), ' ') "Lång_beskrivning", a.mch_code "Objektnr",
    b.mch_name "Objektnamn", replace(a.performed_action_lo, chr(13) ||
    chr(10), ' ') "Utfört arbete", sum(b.amount) "Kostnad", sum(
    b.sales_price_amount) "Kundpris", a.reg_date "Regdatum",
    a.real_f_date "Utf_datum", a.work_master_sign "Arbetsbefäl",
    a.work_type_id "Arbetstyp", a.state "Status"
    FROM objown.active_work_order a, objown.xxx_work_order_coding b,
    objown.cust_ord_customer c
    WHERE b.work_order_account_type = 'Kostnad'
    AND a.wo_no = b.wo_no
    AND a.mch_code = b.mch_code
    AND a.customer_no = b.customer_no
    AND a.customer_no = c.customer_no
    AND b.customer_no = c.customer_no
    AND a.mch_code = b.mch_code
    AND b.order_no IS NULL
    AND a.agreement_id IS NULL
    AND (a.work_type_id = 'L'
    OR a.work_type_id = 'U'
    OR a.work_type_id = 'S'
    OR a.work_type_id = 'T'
    OR a.work_type_id = 'UF')
    AND a.customer_no < '5%'
    AND a.customer_no LIKE '10027'
    AND a.org_code LIKE '510'
    AND a.state LIKE 'Av%'
    GROUP BY a.wo_no, a.customer_no, c.name, a.contact, a.err_descr,
    a.err_descr_lo, a.mch_code, b.mch_name, a.performed_action_lo,
    a.work_master_sign, a.work_type_id, a.reference_no, a.state,
    a.reg_date, a.real_f_date
    When Running as the object owner I get the following costs, is
    Step # Description Est. Cost Est. Rows Returned Est. KBytes Returned
    1 This plan step retrieves a single ROWID from the B*-tree index CUST_ORD_CUSTOMER_PK. 1 1 0,007
    2 This plan step retrieves one or more ROWIDs in ascending order by scanning the B*-tree index ACTIVE_WORK_ORDER_IX4. 1 1 --
    3 This plan step retrieves rows from table ACTIVE_WORK_ORDER_TAB through ROWID(s) returned by an index. 1 1 0,198
    4 This plan step loops through the query's IN list predicate, executing its child step for each value found.
    5 This plan step joins two sets of rows by iterating over the driving, or outer, row set (the first child of the join) and, for each row, carrying out the steps of the inner row set (the second child). Corresponding pairs of rows are tested against the join condition specified in the query's WHERE clause. 2 1 0,205
    6 This plan step retrieves one or more ROWIDs in ascending order by scanning the B*-tree index WORK_ORDER_CODING_PK. 1 1 --
    7 This plan step retrieves rows from table WORK_ORDER_CODING_TAB through ROWID(s) returned by an index. 1 1 0,053
    8 This plan step joins two sets of rows by iterating over the driving, or outer, row set (the first child of the join) and, for each row, carrying out the steps of the inner row set (the second child). Corresponding pairs of rows are tested against the join condition specified in the query's WHERE clause. 3 1 0,258
    9 This plan step retrieves a single ROWID from the B*-tree index ACTIVE_WORK_ORDER_PK. 1 1 --
    10 This plan step retrieves rows from table ACTIVE_WORK_ORDER_TAB through ROWID(s) returned by an index. 1 1 0,014
    11 This plan step joins two sets of rows by iterating over the driving, or outer, row set (the first child of the join) and, for each row, carrying out the steps of the inner row set (the second child). Corresponding pairs of rows are tested against the join condition specified in the query's WHERE clause. 4 1 0,271
    12 This plan step has no supplementary description information.
    13 This plan step designates this statement as a SELECT statement. 5 1 0,271
    AND Running as end user brings the following costs!
    1 This plan step retrieves a single ROWID from the B*-tree index CUST_ORD_CUSTOMER_PK. 1 1 0,007
    2 This plan step retrieves one or more ROWIDs in ascending order by scanning the B*-tree index ACTIVE_WORK_ORDER_IX4. 1 360 --
    3 This plan step retrieves rows from table ACTIVE_WORK_ORDER_TAB through ROWID(s) returned by an index. 29 10 1,982
    4 This plan step loops through the query's IN list predicate, executing its child step for each value found.
    5 This plan step represents the execution plan for the subquery defined by the view ACTIVE_WORK_ORDER. 29 1 4,095
    6 This plan step joins two sets of rows by iterating over the driving, or outer, row set (the first child of the join) and, for each row, carrying out the steps of the inner row set (the second child). Corresponding pairs of rows are tested against the join condition specified in the query's WHERE clause. 30 1 4,102
    7 This plan step retrieves all rows from table WORK_ORDER_CODING_TAB. 26 070 10 0,527
    8 This plan step retrieves a single ROWID from the B*-tree index ACTIVE_WORK_ORDER_PK. 1 1 --
    9 This plan step retrieves rows from table ACTIVE_WORK_ORDER_TAB through ROWID(s) returned by an index. 1 1 0,014
    10 This plan step joins two sets of rows by iterating over the driving, or outer, row set (the first child of the join) and, for each row, carrying out the steps of the inner row set (the second child). Corresponding pairs of rows are tested against the join condition specified in the query's WHERE clause. 26 071 3 0,199
    11 This plan step represents the execution plan for the subquery defined by the view XXX_WORK_ORDER_CODING. 26 071 3 17,748
    12 This plan step accepts two sets of rows, each from a different table. A hash table is built using the rows returned by the first child. Each row returned by the second child is then used to probe the hash table to find row pairs which satisfy a condition specified in the query's WHERE clause. Note: The Oracle cost-based optimizer will build the hash table using what it thinks is the smaller of the two tables. It uses the statistics to determine which is smaller, so out of date statistics could cause the optimizer to make the wrong choice. 26 102 1 10,018
    13 This plan step has no supplementary description information.
    14 This plan step designates this statement as a SELECT statement. 26 103 -- --

    AND a.customer_no < '5%'
    AND a.customer_no LIKE '10027'
    AND a.org_code LIKE '510'
    Does the query bring back the expected results? There appears to be an issue with your customer_no logic. The only customer_no that will meet your criteria is '10027', the < '5%' appears redundant.
    with a as (
       select '10027' customer_no from dual union all
       select '10027x' customer_no from dual)
    select *
    from a
    where a.customer_no < '5%'
    and a.customer_no like '10027';Also, your LIKE operators can be rewritten as '=' if you do not use wildcards, ie '%' or '_'.
    If the active_work_order table is larger than the others, you may want to use the smallest table when comparing the customer_no column as it may assist in the execution path.

  • Query Performance problem after upgrade from 8i to 10g

    Following query takes longer time in 10g.
    SELECT LIC_ID,FSCL_YR,KEY_NME,CRTE_TME_STMP,REMT_AMT,UNASGN_AMT,BAD_CK_IND,CSH_RCPT_PARTY_ID,csh_rcpt_id,REC_TYP,XENT_ID,CLNT_CDE,BTCH_CSH_STA,file_nbr,
    lic_nbr,TAX_NBR,ASGN_AMT FROM (
    SELECT /*+ FIRST_ROWS*/
         cpty.lic_id,
    cpty.clnt_cde,
    cpty.csh_rcpt_party_id,
    cpty.csh_rcpt_id,
    cpty.rec_typ,
    cpty.xent_id,
    cr.fscl_yr,
    cbh.btch_csh_sta,
    nam.key_nme,
    lic.file_nbr,
    lic.lic_nbr,
    cr.crte_tme_stmp,
    cr.remt_amt,
    cr.unasgn_amt,
    ee.tax_nbr,
    cr.asgn_amt,
    cr.bad_ck_ind
    FROM lic lic
    ,csh_rcpt_party cpty
    ,name nam
    ,xent ee
    ,csh_rcpt cr
    ,csh_btch_hdr cbh
    WHERE 1 = 1
    AND ee.xent_id = nam.xent_id
    AND cbh.btch_id = cr.btch_id
    AND cr.csh_rcpt_id = cpty.csh_rcpt_id
    AND ee.xent_id = cpty.xent_id
    AND cpty.lic_id = lic.lic_id(+)
    AND (cpty.clnt_cde IN ( SELECT clnt_cde
    FROM clnt
                   START WITH clnt_cde = '4006'
    CONNECT BY PRIOR clnt_cde_prnt = clnt_cde)
    OR cpty.clnt_cde IS NULL)
    AND nam.cur_nme_ind = 'Y'
    AND nam.ent_nme_typ = 'P' AND nam.key_nme LIKE 'WHITE%')
    order by lic_id
    Explain Plan in 8i
    0 SELECT STATEMENT Optimizer=HINT: FIRST_ROWS (Cost=17 Card=1
    Bytes=107)
    1 0 FILTER
    2 1 NESTED LOOPS (Cost=17 Card=1 Bytes=107)
    3 2 NESTED LOOPS (Cost=15 Card=1 Bytes=101)
    4 3 NESTED LOOPS (OUTER) (Cost=13 Card=1 Bytes=73)
    5 4 NESTED LOOPS (Cost=11 Card=1 Bytes=60)
    6 5 NESTED LOOPS (Cost=6 Card=1 Bytes=35)
    7 6 INDEX (RANGE SCAN) OF 'NAME_WBSRCH1_I' (NON-UN
    IQUE) (Cost=4 Card=1 Bytes=26)
    8 6 TABLE ACCESS (BY INDEX ROWID) OF 'XENT' (Cost=
    2 Card=4649627 Bytes=41846643)
    9 8 INDEX (UNIQUE SCAN) OF 'EE_PK' (UNIQUE) (Cos
    t=1 Card=4649627)
    10 5 TABLE ACCESS (BY INDEX ROWID) OF 'CSH_RCPT_PARTY
    ' (Cost=5 Card=442076 Bytes=11051900)
    11 10 INDEX (RANGE SCAN) OF 'CPTY_EE_FK_I' (NON-UNIQ
    UE) (Cost=2 Card=442076)
    12 4 TABLE ACCESS (BY INDEX ROWID) OF 'LIC' (Cost=2 Car
    d=3254422 Bytes=42307486)
    13 12 INDEX (UNIQUE SCAN) OF 'LIC_PK' (UNIQUE) (Cost=1
    Card=3254422)
    14 3 TABLE ACCESS (BY INDEX ROWID) OF 'CSH_RCPT' (Cost=2
    Card=6811443 Bytes=190720404)
    15 14 INDEX (UNIQUE SCAN) OF 'CR_PK' (UNIQUE) (Cost=1 Ca
    rd=6811443)
    16 2 TABLE ACCESS (BY INDEX ROWID) OF 'CSH_BTCH_HDR' (Cost=
    2 Card=454314 Bytes=2725884)
    17 16 INDEX (UNIQUE SCAN) OF 'CBH_PK' (UNIQUE) (Cost=1 Car
    d=454314)
    18 1 FILTER
    19 18 CONNECT BY
    20 19 INDEX (UNIQUE SCAN) OF 'CLNT_PK' (UNIQUE) (Cost=1 Ca
    rd=1 Bytes=4)
    21 19 TABLE ACCESS (BY USER ROWID) OF 'CLNT'
    22 19 TABLE ACCESS (BY INDEX ROWID) OF 'CLNT' (Cost=2 Card
    =1 Bytes=7)
    23 22 INDEX (UNIQUE SCAN) OF 'CLNT_PK' (UNIQUE) (Cost=1
    Card=1)
    Explain Plan in 10g
    0 SELECT STATEMENT Optimizer=HINT: FIRST_ROWS (Cost=19 Card=1
    Bytes=112)
    1 0 SORT (ORDER BY) (Cost=19 Card=1 Bytes=112)
    2 1 FILTER
    3 2 NESTED LOOPS (Cost=18 Card=1 Bytes=112)
    4 3 NESTED LOOPS (Cost=16 Card=1 Bytes=106)
    5 4 NESTED LOOPS (OUTER) (Cost=14 Card=1 Bytes=78)
    6 5 NESTED LOOPS (Cost=12 Card=1 Bytes=65)
    7 6 NESTED LOOPS (Cost=6 Card=1 Bytes=34)
    8 7 INDEX (RANGE SCAN) OF 'NAME_WBSRCH1_I' (INDE
    X) (Cost=4 Card=1 Bytes=25)
    9 7 TABLE ACCESS (BY INDEX ROWID) OF 'XENT' (TAB
    LE) (Cost=2 Card=1 Bytes=9)
    10 9 INDEX (UNIQUE SCAN) OF 'EE_PK' (INDEX (UNI
    QUE)) (Cost=1 Card=1)
    11 6 TABLE ACCESS (BY INDEX ROWID) OF 'CSH_RCPT_PAR
    TY' (TABLE) (Cost=6 Card=1 Bytes=31)
    12 11 INDEX (RANGE SCAN) OF 'CPTY_EE_FK_I' (INDEX)
    (Cost=2 Card=4)
    13 5 TABLE ACCESS (BY INDEX ROWID) OF 'LIC' (TABLE) (
    Cost=2 Card=1 Bytes=13)
    14 13 INDEX (UNIQUE SCAN) OF 'LIC_PK' (INDEX (UNIQUE
    )) (Cost=1 Card=1)
    15 4 TABLE ACCESS (BY INDEX ROWID) OF 'CSH_RCPT' (TABLE
    ) (Cost=2 Card=1 Bytes=28)
    16 15 INDEX (UNIQUE SCAN) OF 'CR_PK' (INDEX (UNIQUE))
    (Cost=1 Card=1)
    17 3 TABLE ACCESS (BY INDEX ROWID) OF 'CSH_BTCH_HDR' (TAB
    LE) (Cost=2 Card=1 Bytes=6)
    18 17 INDEX (UNIQUE SCAN) OF 'CBH_PK' (INDEX (UNIQUE)) (
    Cost=1 Card=1)
    19 2 FILTER
    20 19 CONNECT BY (WITH FILTERING)
    21 20 TABLE ACCESS (BY INDEX ROWID) OF 'CLNT' (TABLE) (C
    ost=2 Card=1 Bytes=15)
    22 21 INDEX (UNIQUE SCAN) OF 'CLNT_PK' (INDEX (UNIQUE)
    ) (Cost=1 Card=1)
    23 20 NESTED LOOPS
    24 23 BUFFER (SORT)
    25 24 CONNECT BY PUMP
    26 23 TABLE ACCESS (BY INDEX ROWID) OF 'CLNT' (TABLE)
    (Cost=2 Card=1 Bytes=7)
    27 26 INDEX (UNIQUE SCAN) OF 'CLNT_PK' (INDEX (UNIQU
    E)) (Cost=1 Card=1)
    28 20 TABLE ACCESS (FULL) OF 'CLNT' (TABLE) (Cost=5 Card
    =541 Bytes=5951)
    Explain plan looks different in steps 19 to 28. I am not sure why 10g have more steps

    Hi
    I have no experience in 8i. I do know 10g does costing different from 8i. So I think the other plan might got elliminated.
    Normally when I see differences. I just collect statistics on the tables and the indexes and remove the hints. Hints are not good . This has helped me to solve few problems.
    Thanks
    CT

  • WHERE clause in a SMARTFORM loop, problems with parenthesis

    Hi all gurus,
    a simple question: I'm coding a LOOP in the form builder for a smartform ... this simple loop should bind text elements to every position of a purchase order. The WHERE clause should be as follows:
    WHERE GUID = WA_ITEM-GUID
    AND ( TDID EQ 'ZDES' OR TDID EQ 'ZDST' ).
    Anyway, in the Form Builder I didn't find a way to add parenthesis; I workarounded the problem with the following query:
    (conditions in lines are in AND conjunction)
    GUID EQ     WA_ITEM-GUID
    TDID      EQ   'ZDES'
    OR
    GUID EQ     WA_ITEM-GUID                                                                               
    TDID      EQ 'ZDST'.
    It's quite a 'bad' way, but it works. I wonder if there's a way to express "complex" WHERE clauses (with addiction of parenthesis) in Form Builder.
    Thanks in advance

    In this case, your solution is the one that works. However in more complex cases with more variables, this can proove difficult to make or mantain.
    What I usually do is use the first part of the condition in the where and then add a condition to the printing area with the rest of the formula. Just remember to document this so that you'll find it easy and it's way more amintainable.
    In this case the loop would contain WHERE GUID = WA_ITEM-GUID and the inside condition TDID EQ 'ZDES' OR TDID EQ 'ZDST. This creates the and between the two blocks.

  • SQL dynamic query returning (problem with list of value)

    Hi, I'm having trouble with my query. I want to make where statement based on my selectlist, but the problem is that I couldnt write the correct string in my where condition.
    :P61_STATUS has this following display, return value
    Bewerber     Bewerber     
    PRA_Kandidat     PRA_Kandidat          
    abgelehnt     abgelehnt          
    angenommen     angenommen          
    Thema     Thema     
    angemeldet     angemeldet          
    abgegeben     abgegeben          
    abgeschlossen     abgeschlossen          
    bestätigt     bestätigt
    DECLARE
      q varchar2(4000);
      list_betreuer htmldb_application_global.vc_arr2;
      list_semester htmldb_application_global.vc_arr2;
      list_status htmldb_application_global.vc_arr2;
    BEGIN
    -- variable to store the list
    list_betreuer := HTMLDB_UTIL.STRING_TO_TABLE(:P61_BETREUER);
    list_semester := HTMLDB_UTIL.STRING_TO_TABLE(:P61_SEMESTER);
    list_status := HTMLDB_UTIL.STRING_TO_TABLE(:P61_STATUS);
    -- Query begins
    q:= 'select p1.name, p1.vorname , a1.tel, a2.tel, ';
    q:= q||'ab.thema, ab.status, ab.typ, s.bezeichnung, p2.name ';
    q:= q||'from person p1, person p2, adresse a1, adresse a2, ';
    q:= q||'zuordnungp_a zpa1,zuordnungp_a zpa2, ';
    q:= q||'abschlussarbeit ab, semester s ';
    q:= q||'WHERE ab.SEMESTER = s.OBJECTID (+) ';
    q:= q||'AND ab.STUDENT = p1.OBJECTID (+) ';
    q:= q||'AND ab.BETREUER = p2.OBJECTID (+) ';
    q:= q||'and p1.objectid = zpa1.person (+) ';
    q:= q||'and zpa1.adresse  = a1.objectid (+) ';
    q:= q||'and zpa1.art (+)= ''Privat'' ';
    q:= q||'and p1.objectid = zpa2.person (+) ';
    q:= q||'and zpa2.adresse  = a2.objectid (+) ';
    q:= q||'and zpa2.art (+)= ''Geschäft'' ';
    -- Loop for betreuer list
    FOR i in 1..list_betreuer.count
    LOOP
        IF i = 1 THEN
        q:= q||'AND (ab.betreuer = '||list_betreuer(i);
        ELSE
        q:= q||' OR ab.betreuer  = '||list_betreuer(i);
        END IF;
    END LOOP; if (list_betreuer.count>0)THEN q:= q||')'; END IF;
      -- Loop for semester list
    FOR i in 1..list_semester.count
    LOOP
        IF i = 1 THEN
        q:= q||'AND (ab.semester = '||list_semester(i);
        ELSE
        q:= q||'OR ab.semester = '||list_semester(i);
        END IF;
    END LOOP; if (list_semester.count>0)THEN q:= q||')'; END IF;
    -- Loop for status list
    FOR i in 1..list_status.count
    LOOP
        IF i = 1 THEN
        q:= q||'AND (ab.status = '||list_status(i)||'';
        ELSE
        q:= q||'OR ab.status = '||list_status(i)||'';
        END IF;
    END LOOP; if (list_status.count>0)THEN q:= q||')'; END IF;
      htp.p(q);
    return q;
    END;result
    select p1.name, p1.vorname , a1.tel, a2.tel, ab.thema, ab.status, ab.typ, s.bezeichnung, p2.name from person p1, person p2, adresse a1, adresse a2, zuordnungp_a zpa1,zuordnungp_a zpa2, abschlussarbeit ab, semester s WHERE ab.SEMESTER = s.OBJECTID (+) AND ab.STUDENT = p1.OBJECTID (+) AND ab.BETREUER = p2.OBJECTID (+) and p1.objectid = zpa1.person (+) and zpa1.adresse = a1.objectid (+) and zpa1.art (+)= 'Privat' and p1.objectid = zpa2.person (+) and zpa2.adresse = a2.objectid (+) and zpa2.art (+)= 'Geschäft' AND (ab.status = abgegeben) the problem is in this statement
    q:= q||'AND (ab.status = '||list_status(i)||'';that statement produce this following statement
    ab.status = abgegebenbut what I need is this statement
    ab.status = 'abgegeben';how can I achieve this statement?
    thank you very much

    raitodn wrote:
    ah ok , I was confused with this q:= q||'AND (ab.status = '''||list_status(i)||'''';I think I get it now
    basically stop the string and write double quotes before the variable
    'AND (ab.status = ' + ''||list_status(i)||'' + ''No, more like "wherever I want a single quote within a string, I put two single quotes instead and that tells oracle it's a quote and not the end of the string".
    q:= q||'AND (ab.status = '''||list_status(i)||'''';
           ^                 ^^^                  ^^^^
           |                 |/|                  ||/|
           |                 | |                  || \-- single quote indicates end of string
           |                 | |                  ||
           |                 | |                  |\-- two quotes indicate a single quote required
           |                 | |                  |
           |                 | |                  \-- single quote to open a new string
           |                 | |
           |                 | \-- single quote indicates end of string
           |                 |
           |                 \-- two quotes indicate single quote required
           \-- Open String

Maybe you are looking for

  • Redo log add and new group

    Hi, I have problem with one of the redo log file i issued the ALTER DATABASE CLEAR LOGFILE GROUP 3; command. the status right now is clearing since last some hours. Can i create new redo log and assign to group 3. will the status will be inactive or

  • How to syncing my ipod touch to my pc

    I have all my music tracks on my pc but I have lost them on my ipod touch how can I restore them to my ipod (syncing)

  • 2 months + to have the phone, ... in London???!

    I first contacted BT on the 11th Aug to transfer our telephone line and have a broadband installed in our new flat. Nothing extraordinary for an institution like BT, as we live in central London (W1) and we just moved a few blocks away… Delay after d

  • Time Machine preparing WAY too many items

    I just noticed that my Time Machine backups are taking an unusually long time. So when the last one finished, I immediately ran a second backup with Time Machine preferences open so I could watch the progress bar. It said it was "Preparing (about) 3,

  • ITunes Downloading Video Podcasts - Hangs a few minutes on save

    I have iTunes 8 (but this has been going on in older versions) On a Win XP Pro laptop with 2GB Ram, and a 10mb Internet connection. When I download new podcasts, the video podcasts download OK, but when each one completes the download and I assume is