'Order By' in Exists / Not Exists condition causing ORA-00907 in Apex4.1.1

Hi Guys,
We have just upgraded from apex 3.2.1 to 4.1.1. on Oracle DB V11.2.0.1, while testing the apps in apex, I come across this problem.
When I have a page process that has a condition defined.
When Condition Type is Exists (SQL query returns at least one row) or Not Exists (SQL query returns no rows) and the Expression 1 is a query with an 'Order By' clause, e.g.
SELECT 123 FROM DUAL
ORDER BY 1
When the process is triggered, Apex 3.2.1 would evaluate the condition and run the process just fine, however Apex 4.1.1 would throw an error : ORA-00907: missing right parenthesis
I totally understand that an Order by clause in an Exists or Not Exists condition is unnecessary and agree that they shouldn't be there in the first place.
But unfortunately I am dealing with other developers codes and these conditions have been coded like these, probably from copy & paste codes.
Saying that, I also believe that an Apex upgrade should not stop anything that is working in previous releases without warning or provide a workaround, right?
I don't know if this affects other types of artifacts that can have a condition in apex when upgrading from 3.2.1, e.g Regions/Items/Computations/Validations etc.
Does anyone else get this behaviour? and is there an easy solution to fix these?
Ideally I don't want to go through all processes (and whatever other artifacts might be affected too) in all apps in all workspaces to check the condition type and remove the 'Order By' clause manually.
Thanks for any advises
Just did some more testing
'Computation' , 'Validations', 'Processes' and 'Branches' have the same problem, 3.2.1 takes 'Order By' fine in Exists/Not Exists condition, but 4.1.1 throws error.
'Regions', 'Buttons', 'Items' have consistent behaviour - both 3.2.1 and 4.1.1 throw error ORA-00907: missing right parenthesis, when page is rendered.
Edited by: Danny on 25/04/2012 20:07

Hi Danny,
that's interesting. I just had a look what happens when you use an EXISTS or NOT EXISTS condition type. The following final SQL statement will be generated with your above example. You can also see that if you run your application in debug mode.
select count(*) from sys.dual where exists (select 123 from dual order by 1)Executing that statement in SQL*Plus will also show the ORA-00907 error. It appears that the SQL parser doesn't allow an order by clause in an EXIST clause.
I wonder why this should have worked in previous versions, but I can only suspect that in the past we may just have executed
select 123 from dual order by 1which can be slightly slower because with the new EXISTS statement the SQL engine can stop processing earlier if it finds a record.
We try to be backward compatible as much as possible, but I doubt that we will change that back to the way it was before because of the performance penalty 99.9% of our customers would face.
Possible Workaround: You might be able to use the new "Application Search" to scan your application for "order by" and fix it for all hits where the attribute name is "Expression 1".
Regards
Patrick
My Blog: http://www.inside-oracle-apex.com
APEX Plug-Ins: http://apex.oracle.com/plugins
Twitter: http://www.twitter.com/patrickwolf

Similar Messages

  • How do I order ResultSet AND update? My attempts yield ORA-00907 or  ORA_01732

    I am using JDev 9.0.3 to create an application I run using Java 1.3.1 and Oracle 9.2.0.1.0 JDBC drivers.
    I want to select the rows of a single table ordered by a "sortorder" column, iterate through the records, update as required, and occasionally move to the insert row, insert a record, and move back to where I left off.
    Can anyone supply the recommended way to do this?
    Now if I drop the "order by" clause/requirement I can do this just fine.
    However, if I add the "order by" clause (as below) I get error ORA-01732 "manipulation operation not legal on this view" when issuing rs.insertRow() (note NOT moveToInsertRow(), updateLong(), etc. but the actual insertRow() )
    myconn.prepareStatement(
    "select rowid, temptopsort.* from temptopsort order by sortorder"
    , ResultSet.TYPE_SCROLL_INSENSITIVE
    , ResultSet.CONCUR_UPDATABLE
    I get this same result with ResultSet.TYPE_SCROLL_SENSITIVE, with JDK 1.4.1 (and appropriate Oracle ojdbc14.jar, etc.)
    So again my questions is HOW DO YOU ITERATED THROUGH AND ORDERED RESULT SET AND UPDATE/INSERT?
    Thanks
    R.Parr
    Temporal Arts

    Thomas,
    Oracle was the first RDBMS I used (way back, around the year 1990, I believe). Several years later, I moved from Oracle to Informix. It took me a long time to realize that, although Informix and Oracle are both RDBMSs, they are very different. What I needed to do was forget how I used to work with Oracle, and learn how to work with Informix.
    Naturally, before I came to this realization, I spent a lot of energy cursing Informix and wondering, "why doesn't it work like Oracle does?"
    However, after I made the "mind-switch", and learned to do things the Informix way, everything was smooth sailing (and very enjoyable, too :-)
    So I'm only guessing, of-course, but I get the feeling that you may be encountering a similar reaction to me, now that you are migrating from "MySQL" to "Oracle".
    The usual advice I see given to people in (what I assume to be) your situation, is to peruse the Oracle documentation and/or the book "Expert One-on-One Oracle" by Thomas Kyte.
    Good Luck,
    Avi.

  • Advanced Conditions causing ORA-00904 invalid identifier

    I have another weird thing going on...
    It may be the complexity of the data I'm pulling, but I'm going to simplify the problem first...
    I have several conditions in my workbook that I need to be true regardless then I need the following (this is a payroll thing):
    ((Total Regular Hours > 40 AND Total Overtime = 0) OR (Total Overtime > 0 AND (Total Regular Hours - Total Overtime Hours) <> 40))
    So, I'm using Discoverer Plus 10g and if I create separate conditions for Total Overtime > 0 and (Total Regular Hours - Total Overtime Hours) <> 40) it will work, but if I try to combine them into one condition (so I can then add my OR and the other 2 conditions) it gives me the "ORA-00904 invalid identifier" error and will not run.
    The only way I've been able to do it is to create 3 conditions and 2 worksheets. That way, I can add (Total Regular Hours > 40 AND Total Overtime = 0) in one condition and apply it to one sheet; then I the other 2 separate conditions can be applied to the other worksheet.
    I hate having to have 2 worksheets when I should be able to create an advanced condition... anyone have any ideas?
    Regards,
    Emily

    It is actually a typo in the message because I have a calculated column that calculates the difference... sorry.
    I did try the idea of running the SQL that was generated in SQL Developer and it doesn't look right.
    It did all my other conditions under the where, but then where I would have thought it should do another and it did a WHERE.... see below. (I only pasted from the from statement on to save room)
    FROM HRBG_PEOPLE_ASSIGNMENT o393615, APPS.PTEN_PAY_BEE_V o393616
    WHERE ( (o393616.ASSIGNMENT_ID = o393615.ASSIGNMENT_ID))
    AND (o393615.BG_SECURITY_FLAG_CODE = 'Y')
    AND (o393616.DATE_EARNED BETWEEN o393615.ASSIGNMENT_START_DATE AND o393615.ASSIGNMENT_END_DATE AND o393616.DATE_EARNED BETWEEN o393615.RECORD_START_DATE AND o393615.RECORD_END_DATE)
    AND (o393616.DATE_EARNED IN (:"Date Earned Dates"))
    AND (o393616.EFFECTIVE_DATE = :"Period End Date")))))
    WHERE ( ( NP100 ) > 40 AND ( NP101 ) = 0)
    AND ( ( NP104 ) <> 40 AND ( NP105 ) > 0)
    ORDER BY E393849 ASC ;
    Do you see the WHERE that I marked in BOLD? That should be an AND...
    I even tried creating one crazy long condition to include everything in one and still got the same error and it produced the same SQL. I am thinking it has to do with the fact that I'm actually showing group totals for Regular Hours and Overtime and then subtracting them to get the difference. It all breaks when I add that difference in with the others. If I keep it separate, it does fine.
    By the way, the error I get when running just the SQL is "not all variables bound"
    Thanks,
    Emily

  • Response time performance for the NOT EXISTS condition

    Hi all,
    In the query below, there is the WHERE NOT EXISTS condition based on a view. And I want to know what is the better choice to take whether to include the DISTINCT keyword in the select script of the view or not , because the view contains duplicated rows :
    select * from table_name table_alias where not exists( select 1 from the_view_name where join_condition);
    Thank you very much indeed

    Sometimes it is, sometimes it isn't, usually it's the same. The optimizer will tend to rewrite the query as a join anyway if it can.
    For some notes on the options available to the optimizer for an EXISTS subquery:
    http://jonathanlewis.wordpress.com/join-ordering-pt2
    Most if not all of those are also possible for an IN subquery (couldn't find a link just now but I have to go to work).

  • BAPI_PO_CHANGE not updating existing condition type value.

    Hi,
    I am using 'BAPI_PO_CHANGE' to update the existing condition records.
              MOVE-CORRESPONDING wa_pocond_40 TO gt_pocond_40.
              gt_pocond_40-change_id = 'U'.
              gt_pocond_40-cond_value = '20'.
              gt_pocondx_40-itm_number = <fs_pocond_41_new>-itm_number.
              gt_pocondx_40-cond_st_no  = <fs_pocond_41_new>-cond_st_no.
              gt_pocondx_40-itm_numberx = 'X'.
              gt_pocondx_40-cond_st_nox = 'X'.
              gt_pocondx_40-cond_type = 'X'.
              gt_pocondx_40-cond_value = 'X'.
              gt_pocondx_40-currency = 'X'.
              gt_pocondx_40-change_id = 'X'.
              MODIFY gt_pocond_40 INDEX sy-tabix.
              APPEND gt_pocondx_40.
    I am using 'BAPI_TRANSACTION_COMMIT' also.
    Still, the condition value is not changing.
    what and where do u think is the problem?
    Kindly assist.
    Thanks.

    check the following link
    http://www.sap-img.com/abap/sample-abap-code-on-bapi-po-change.htm

  • Decode for EXISTS and  NOT EXISTS conditions

    Hello all,
    I need to use either EXISTS or NOT EXISTS before the subquery based on the situation. I have written a test query but its erroring out. Please check it.
    select 1 from dual
    where DECODE('A','A',EXISTS ,NOT EXISTS)
    (select ename from EMP
    where ename = 'SCOTT')
    Thank You
    KK

    DECODE will not replace part of the query. Functions don't work that way.
    (It won't work if you put EXISTS and NOT EXISTS in quotes, either.)
    What you want is something like
    WHERE (<condition> AND EXISTS...) OR (<not-condition> AND NOT EXISTS...)You can also do:
    SELECT 1
    FROM dual
    CROSS JOIN (SELECT COUNT(1) AS exists_fg FROM emp WHERE ename = 'SCOTT') ex
    WHERE (<condition> AND exists_flag > 0) OR (<not-condition> AND exists_flag = 0)This way, you don't have to include the entire WHERE EXISTS condition twice.
    -- Don

  • Production scheduling profile for production order type 10 does not exist – SAP Message No.10085

    When i tried to make confirmation for Production Order through CO15 transaction , i receive the following error message “ Production scheduling profile for production order type 10 does not exist – SAP Message No.10085 “
    In Work Scheduling view, Production Scheduling Profile is maintained as per OPKP only.
    How to check whether production scheduling profile is maintained for relevant order type 10.
    To do this , i went to OPKP & KOT2_OPA transactions but i don’t know how to check. I guide me through with a screen shot.
    Also, pls explain about  “Order Type 10” and how it is linked with material and order execution.
    Looking for a detailed explanation with screen shots , since i am new to SAP.
    Thanks With Regards,
    Dinesh Kumar V.

    Hello Dinesh,
    Please check the order type dependent parameter in OPL8 here you will get the Substitute Scheduler
    Then go to OPCH and check valid production scheduling profile assign here as per OPKP to your production scheduler for your plant.
    Production order have Order category as 10  Process Order  40 in standard SAP you can check this in OPJH.
    Best Regards,
    R.Brahmankar

  • Production scheduling profile for production order type 10 does not exist

    Kindly suggest me how to resolve this error
    Production scheduling profile for production order type 10 does not exist

    Hi Archana,
    Go to material master-work scheduling view and check what is the production scheduling profile maintained for the same materisl -plant combination.
    then go to OPKP and check if production scheduliong profile is maintained for relevent order type 10 in custmizing. If not maintain one and it should resolve the error.

  • Add a new field to an existing Condition table

    How can I add a new field to an existing condition table?
    I have table 971 and I want to add INCOTERMS (INCO1) to this existing table but do not see how to add it.
    Thanks

    Hi Vicky,
        I dont think you can add new fields to the condition table once you have activated the condition table.
    SAP says you can only make limited changes to the condition table, like changing the description, fast entry screen, header and footer fields, but not able to add new fields to the table, and I think that is the correct approch or else for the same table you will have two sets of condition records.
    Please refer to the below link:
    http://help.sap.com/saphelp_erp60_sp/helpdata/en/de/7a8534c960a134e10000009b38f83b/frameset.htm
    What you can do is create a new condition table with additional field and assign this table before the currently used table in the access sequence.
    Hope this helps.
    Regards
    Raj

  • Sales Order Stock Doesnt Exist in Delivery

    Hi all,
    I had converted the Vendor Consignment stock into Sales order Stock. Later, i try to issue the material against same Sales Order but system wont alllow me to do so.
    It says "Sales Order Stock XXXXX  does not exist" where XXXXX is my sales order number. (Message M7 184)
    But when i checked the Sales Order Stock using  MMBE or MB52 Report,  it is there.
    I'm not able to figure it out why system is thorwing this message when material is there.
    Pls note: Material used in Scenario is Split valuated.
    regards,
    S Anand

    Hi Friend
    I had converted the Vendor Consignment stock into Sales order Stock
    I dont know what is your process and what is the meaning of this statement
    But i feel there is some mistake happening here only
    For the System to acknowledge or to accept for the sales order stocks during PGI the prerequiest is
    When the sales order is created, the sales order item category should have special stock indicator E in its details in VOV7
    Otherwise system will not sense during PGI even if you have stocks showing against your sales order no in MMBE
    Say an order is created with item category without being marked special stock indicator E
    After the sales order is saved you note down the no and reserve stocks in MB1B movement type 412 E against your sales order
    Now in MMBE the system will show the reservation against your order no with all details
    When you do PGI the system will take stocks from unrestricted not the reserved qty (its own reservations) if stocks are not there in unrestricted system will give same message as what you have got without sensing the reservation
    All this is because item category is not with special stock indicator E during order creation
    Regards
    Raja

  • Import new sales order line in existing sales order

    Hi All,
    I want to import new sales order line in existing sales order using these open Interface tables or APIs.
    I did some test but the import request always give me the error message:
    You are trying to insert an existing order or update an order that does not exist. Please enter a correct operation code.
    Help..
    BR,
    Edited by: user7993358 on 2011/5/26 下午 8:48

    Hi,
    The script available in Oracle Note 746796.1 may be of help with your troubleshooting.
    Cheers,
    Arun

  • Error "Operation in order 221234 doesnot exist" while doing confirmation

    Hello Friends,
    When i am doing the collective confirmation against the corrective maintenance order or order type CORR, by transaction IW44, getting the error message as "Operation in order 221234 doesnot exist".
    Whereas when i checked in PM Order , in operation tab i am able to see the operation with control key PM01, and 1800 as work involved in the activity.
    This order is having the status as PCNF. When i checked Documents for order - Document flow than i found that till date user has done the confirmation of 1026.8 actual work.
    Hence unable to understand why system is not allowing to do the further confirmation and throwing the error message as stated above.
    Waiting for your valuable reply.
    Thanks and Regards,
    Jitendra Chauhan.

    Hello Friends,
    Found out the solution.
    In transaction iw44 (PM Order Confirmation: Collective Confirmation), With Order Number, Act. Work, also have to give the operation number. If you maintain all these paramters than system doesn't throw the error message.
    Thanks and Regards,
    Jitendra Chauhan.

  • BAPI:Create sales order from an existing open sales order for open items

    Dear All,
    Could any one suggest me any BAPI that can create sales order from an existing OPEN sales order for OPEN items. since we are closing all open orders and creating new orders with reference to existing open orders.   please suggest, its would be great help.
    Regards,
    Reddy

    hi suresh,
    we are changing tax procedure from formula to condition based, so this is the reason we have close all the open orders and recreate in TAXINN procedure, it is going to be large number of records( open orders), so....
    Regards,
    Reddy

  • Ordered Bundle With Existing Service

    I ordered the phone + internet bundle for 69 / mo. The offer includes a free laptop or Flip camera. When I ordered online, it did not give me the option to choose which free gift I wanted. So I called, and Verizon verified my order, etc. but they said they could not guarantee that I would receive the free gift because I was an existing customer. So then transferred me over to the E center whatever and I have been transferred 4 times now, every time someone comes on, I state my issue and they say "ok hold on and i'll get that taken care of" then I'm on hold forever. What the heck?
    Anyone else deal with this? 
    Solved!
    Go to Solution.

    Yeah, existing customers should be treated even better than new customers IMO.

  • Create condition record with reference to existing condition record

    how to create condition record with reference to existing condition record?

    Hi,
    See this link :
    http://help.sap.com/saphelp_47x200/helpdata/en/de/7a8534c960a134e10000009b38f83b/frameset.htm
    You can create with reference with Tcode : VK14 (or VK34)
    Or in VK12, you can copy condition records with copy rules.
    Regards,
    Lionel

Maybe you are looking for