OrderBy Clause

I have a VO with Query statement:
SELECT ......
FROM URRSHIS
WHERE ...........
ORDER BY URRSHIS_ACTION_DATE DESC, URRSHIS_SCAT_CODE
when I try to get OrderBy clause by following code ,I get null:
oracle.adf.model.BindingContext bctx = oracle.adf.model.BindingContext.getCurrent();
oracle.binding.BindingContainer bindings = bctx.getCurrentBindingsEntry();
DCBindingContainer bindingImpl = (DCBindingContainer)bindings;
DCIteratorBinding iter = bindingImpl.findIteratorBinding("URRSHISIterator");
ViewObject vo = iter.getViewObject();
String O = (String) vo.getOrderByClause();
why? I am using Jdev 11.1.2

OK, I would say that this is a bug. I tested this under 11.1.1.7.0 and also got 'null' as result. It doesn't matter if the vo is based on a vo or not.
However, as long as you don't log a bug with support and it's not confirmed by support it not a bug.
As a workaround you can use the
String sql = vo.getQuery();to get the whole sql statement. Then you can use normal string methods to extract the 'order by' clause.
Timo

Similar Messages

  • ADF VO bind variable does not work in 'OrderBy' clause

    Hello, All
    When trying to define a VO with a SQL query, we use VO bind variables on the 'OrderBy' clause and set Groovy expression to populate values at runtime. Based on simple experiments, ADF throws out an exception saying that "Attempt to set a parameter name that does not occur in the SQL'. I am wondering if it is allowed to use bind variables in a 'OrderBy' clause? I know it does in 'Where' clause.
    Thanks a lot for your answers.
    Regards,
    David

    So is there any change of the BC framework being corrected to allow this, since it is legal syntax, as in the following sql*plus example?
    select last_name, decode(&&1, 'SA_REP', nvl(commission_pct,0), 'SA_MAN', nvl(commission_pct,0), nvl(salary,0))
    from hr.employees
    where job_id = &&1
    order by decode (&&1, 'SA_REP', nvl(commission_pct,0), 'SA_MAN', nvl(commission_pct,0), nvl(salary,0))
    /

  • PLS HELP ! WLS 6.1 CMP ejb query ORDERBY clause

    Please Help,
    How to do OrderBY clause ASC and DESC in weblogic 6.1 CMP?
    Thanks

    Hi Deepak,
    First of all, thanks for answering.
    Do you mean I should place that query within "weblogic-query" tag in the weblogic-cmp-rdbms-jar.xml?
    I tried comment the query part in ejb-jar.xml with the ammended weblogic-cmp-rdbms-jar.xml.
    The ejb compiler fail to compile the ejb because it cannot find the coresponse
    Method.
    Can you state a simple example this case with descriptors?, the descriptor make
    me headache. Thanks
    Deepak Vohra <[email protected]> wrote:
    The WebLogic Query Language extension, ORDERBY, is a keyword that works
    with the Finder method to allow you to specify which CMP file you want
    to use for your selections.
    The following example shows the use of the extension, ORDERBY.
    SELECT A from A for Account.Bean
    ORDERBY A.id ASC | DESC
    ASC | DESC
    Specify whether the ordering sequence is ascending or descending. ASC
    is the default.
    Ray wrote:
    Please Help,
    How to do OrderBY clause ASC and DESC in weblogic 6.1 CMP?
    Thanks

  • Using orderby clause when defining a view

    Hi,
    In oracle documentation they specified the query that defines a view cannot contain the ORDER BY or FOR UPDATE clauses.
    But according to the book oracle DBA certification exam (by JASON S.COUCHMAN) the query that defines a view can contain the ORDER BY clause.
    Can anyone help me clarify, whether we can use order by clause in defining a view

    Hi,
    THere are two classifications for views:simple and complex.A complex view can contains functions or groups of data.Use syntax:
    Create view dept_sum_vu
    (name,minsal,maxsal,avgsal)
    as select d.name,MIN(e.sal),MAX(e.sal),AVG(e.sal)
    from emp e,dept d
    where e.deptno=d.deptno
    group by d.dname
    Hope it will work.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by moturideepa([email protected]):
    Hi,
    In oracle documentation they specified the query that defines a view cannot contain the ORDER BY or FOR UPDATE clauses.
    But according to the book oracle DBA certification exam (by JASON S.COUCHMAN) the query that defines a view can contain the ORDER BY clause.
    Can anyone help me clarify, whether we can use order by clause in defining a view<HR></BLOCKQUOTE>
    null

  • Dynamic orderby clause for multiple columns with out Dynamic query

    Hi,
            I've a query like
    "select  * from tablename order by column1,column2,column3,column4,column5,column6"
    in the above query the order by column will be dynamically changed. The query is placed in a stored procedures and the order by column will come by parameter.
       For ex: @orderbycol = column2,column1,column3,column4,column5,column6
                                         or
                    @orderbycol = column3,column2,column1,column4,column5,coumn6
    How can we manage the order by clause as dynamically without go to dynamic query.

    ORDER BY CASE @sortcol1
                 WHEN 'col1' THEN col1
                 WHEN 'col2' THEN col2
             END,
             CASE @sortcol2
                 WHEN 'col1' THEN col1
                 WHEN 'col2' THEN col2
             END,
    Note: these CASE expressions assumes that all columns have the same data type.
    You could consider sorting in the presentation layer instead.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Order by clause require dynamic value

    Hi
    I want to bind parameters to orderby clause. In where clause with bind parameter works fine. But in orderby clause ive done similar steps to have a dynamic sort which will be passed from the previous page in a session variable. Although it didnt show any error at the backend where i can see data getting binded, but no sorting is taking place.
    Can u help me to solve this.
    regards
    Jayashri

    Jayashri,
    I have tested this and you are right. And there does occur an error at the backend, only you wont see it unless you run with BC4J debug mode turned on. You can do this by providing -Djbo.debugoutput=console to the JVM. When running inside JDeveloper, you can accomplish this by going to Project Properties => PRofiles => Development => "Runner", and fill this in at the "Java Options" field.
    Doing that will show the reason of the problem. When a view object is queried, BC4J actually performs 2 queries. One to obtain the 'estimated row count', and then one to obtain the action rows.
    Now suppose your query looks like this:
    SELECT <somefields> FROM <table>
    WHERE <field> = :1 ORDER BY :2
    Bc4j will construct the following query to obtain the estimated rowcount:
    SELECT count(1) FROM (SELECT <somefields> FROM <table> WHERE <field> = :1)
    As you can see, it does NOT include the ORDER BY of the original query in this statement, probably for performance reasons (why order the set if you are only interested in the count). Unfortunately, it WILL try to bind both :1 AND :2 to this query, but because there is only one bind variable in this query, this throws an java.sql.SQLException which is unfortunately trapped somewhere in BC4J code, and not shown in the regular log file.
    I am pretty confident that this is actually a BC4J bug (or known restriction). You could post this problem at the JDeveloper Forum to determine this (without mentioning JHeadstart, because this would also happen if you wrote your own code for binding these parameters).
    As for a workaround, you could try the following:
    1.) Remove the (bind parameter from) the order by clause on the ViewObject
    2.) Remove that same bind parameter from the "Query Bind Parameters" property.
    You should now have gone back to a scenario where there are only bind parameters on the where clause. You would need to set the OrderBy clause programatically now. To do this, extend the JhsDataAction for this page, and override the method 'applyIterBindParams()'. Before calling super, try something like:
    ViewObject vo = ib.getRowSetIterator().getRowSet().getViewObject();
    vo.setOrderByClause(<your dynamic orderby>);
    Kind regards,
    Peter Ebell
    JHeadstart Team

  • How to Modify Order by clause of standard VO

    Hi All,
    I want to modify orderby clause of standard VO. I extended the VO and modified the order by clause. But it did not workout.
    Anybody worked on this kind of requirement?
    Any help would be greatly appriciated.
    Thanks in Advance.
    Rakesh.

    Hi user2705625,
    After extending the VO , one needs to do. jpx import to reflect the changes on to the application server . Please check the link below for steps
    https://blogs.oracle.com/prajkumar/entry/eo_based_vo_extension_in
    Thanks
    Sandeep

  • Order by rowid clause added without my knowledge in Reports gen package

    I have a devlp system and a production system.(3.0.9.8.0)
    I built a report with lots of decode, sum, roll up, group by
    clauses to create a cross table summing matrix report. It ran
    correctly in the Devlp Portal system.
    I exported it and imported this into the Production system.
    Few weeks later I realized that the same report was not working
    on the Production system. After some debugging, I noticed in
    the generated PLSQL package body there is a if-else block that
    basically adds "order by rowid" when the orderby clause is null.
    However, the package body on the devlp system does not do
    that. The only IF block it has is to determine if it needs to
    apply the order by clause or not, no "else"
    This additional generated "order by rowid" is breaking the
    report because it will not work with my group by query.
    My question is - How did that get added into the plsql
    package, when I did not check anything to make that happen ??
    -Ananth

    I am getting similar execution plan on huge data. I cannot post the query here but here is the execution plan:
    Execution Plan [with order by clause]
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=22644 Card=4303 Byte
    s=3795246)
    1 0 COUNT (STOPKEY)
    2 1 NESTED LOOPS (OUTER) (Cost=22644 Card=4303 Bytes=3795246 )
    3 2 VIEW (Cost=9735 Card=4303 Bytes=2263378)
    4 3 SORT (ORDER BY) (Cost=9735 Card=4303 Bytes=529269)
    5 4 FILTER
    6 5 TABLE ACCESS (FULL) OF 'A' (Cost=9542 Car
    d=4303 Bytes=529269)
    7 5 TABLE ACCESS (BY INDEX ROWID) OF 'B' (Cost
    =3 Card=1 Bytes=11)
    8 7 INDEX (UNIQUE SCAN) OF 'B_PK' (UNIQUE) (
    Cost=2 Card=1)
    9 5 TABLE ACCESS (BY INDEX ROWID) OF 'A' (Cos
    t=5 Card=1 Bytes=14)
    10 9 INDEX (RANGE SCAN) OF 'A_X_KEY' (
    UNIQUE) (Cost=3 Card=1)
    11 5 TABLE ACCESS (BY INDEX ROWID) OF 'B' (Cost
    =3 Card=1 Bytes=11)
    12 11 INDEX (UNIQUE SCAN) OF 'B_PK' (UNIQUE) (
    Cost=2 Card=1)
    13 2 TABLE ACCESS (BY INDEX ROWID) OF 'B' (Cost=3 Car
    d=899140 Bytes=320093840)
    14 13 INDEX (RANGE SCAN) OF 'B_XXX_X' (NON-UNIQUE) (
    Cost=2 Card=899140)
    query 2[ without sort]
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=23349 Card=4303 Byte
    s=26592540)
    1 0 COUNT (STOPKEY)
    2 1 VIEW (Cost=23349 Card=4303 Bytes=26592540)
    3 2 SORT (ORDER BY STOPKEY) (Cost=23349 Card=4303 Bytes=20
    61137)
    4 3 FILTER
    5 4 NESTED LOOPS (OUTER) (Cost=22451 Card=4303 Bytes=2 061137)
    6 5 TABLE ACCESS (FULL) OF 'A' (Cost=9542 Car
    d=4303 Bytes=529269)
    7 5 TABLE ACCESS (BY INDEX ROWID) OF 'B' (Cost
    =3 Card=899140 Bytes=320093840)
    8 7 INDEX (RANGE SCAN) OF 'B_XXX_X' (NON-UNI
    QUE) (Cost=2 Card=899140)
    9 4 TABLE ACCESS (BY INDEX ROWID) OF 'B' (Cost=3
    Card=1 Bytes=11)
    10 9 INDEX (UNIQUE SCAN) OF 'B_PK' (UNIQUE) (Co
    st=2 Card=1)
    11 4 TABLE ACCESS (BY INDEX ROWID) OF 'A' (Cost=
    5 Card=1 Bytes=14)
    12 11 INDEX (RANGE SCAN) OF 'A_X_KEY' (UN
    IQUE) (Cost=3 Card=1)
    13 4 TABLE ACCESS (BY INDEX ROWID) OF 'B' (Cost=3
    Card=1 Bytes=11)
    14 13 INDEX (UNIQUE SCAN) OF 'B_PK' (UNIQUE) (Co
    st=2 Card=1)

  • ORDERBY Command

    Does anyone know the limit for the number of members to sort in a report script using the ORDERBY command and how to get around it? Thanks,

    The orderby clause is used to sort data based on a data column, not members. so one would think that after a couple of columns it would become less meaningful. that said.
    I don't know if there is a limit on the number of data columns you can order by, the documentation jsut says must be a number between 1 and the maximum number of columns in the report. (remember these are data columns)

  • Order by with a criteria

    Hi to all
    I would set an orderby clause in a query and set the attribute with a value from a selectOneChoice from the page, how can i do?
    Someone has a resource that explain this?
    Thanks very much in advance

    You can use an AM Service method to do this.
    Similar to this but using a setOrderBy method:
    http://blogs.oracle.com/shay/2010/07/am_service_method_-simpledem.html

  • ORA-00907 in a simple query from dual

    Hi,
    Anybody knows the reason for obtain ora-00907 when we enclose between parenthesis a SQL sentence whith an orderby clause?. Look at the last example:
    --> SQL fine
    select 'A' zz from dual order by 1;
    (select 'A' zz from dual) order by 1;
    select * from (select 'A' zz from dual order by 1);
    --> ORA-00907     Why?
    (select 'A' zz from dual order by 1);
    Regards
    Carlos

    you don't need order by in inlinew view
    if you want order by use
    select * from (select 'A' zz from dual ) order by 1;

  • How to add a calendar Entry on top

    Hi,
    We have an requirement where client wants that if an entry is added in an calendar (All day recurrent event) then that entry should come on top. The OOTB behavior is that if any  "All day recurrent" entry is added or modified for any day,
    it will automatically come to the bottom on that day. Our requirement is that it should come on top on that day.
    Any help will be appreciated.
    Regards,
    Vijay

    Hi Vijay,
    According to your description, my understanding is that you want to re-order all day events on calendar view in SharePoint 2010.
    You can save the calendar list as a template, download the file and change it to a CAB file, then open the file, open the mainifest.xml, then change the “OrderBy” clause based on the
    Created column.
    After that, you need to re-add the xml  file into the CAB file, then change the CAB to stp file, and upload the CAB file into SharePoint.
    More information, please refer to the link:
    http://nickgrattan.wordpress.com/2008/01/23/re-ordering-all-day-items-in-a-calendar/
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Any way to set the sort order other than in the query?

    The report has an OrderBy parameter so the user can select which field is used for sorting. The query has an OrderBy clause referencing the parameter. The problem is that it doesn't always pay any attention to the parameter. (Since it appears to be intermittent my suspicion is that it really never pays any attention to it but that sometimes whatever actually is determining the order gives the same results.)
    The problem is that putting an OrderBy clause in a query is the only way I know of to determine the output order of a report. Is there any other way?
    Thanks.

    Unfortunately Break Order doesn't seem to be controlling the sort order. I found that the value was set on numerous fields but I've changed them all to None & it still isn't displaying in the order specified by the OrderBy parameter.
    Note that this is a 'form layout' report with one page/record so it doesn't really have columns-but the pages are supposed to be printed in the order chosen by the user from a list of values. It doesn't seem to matter what's selected from that list though, the output appears in the same order as if no Order By clause is specified.
    Can you think of anything else that would cause the report to ignore the order by clause?
    thanks.

  • BC4J: embedding Special SQL in View Objects

    While BC4J allows for easier development because developers do not need to embed a lot of SQL in Java codes, I wonder how I could embed special SQLs either into my Java code or in the View Object Wizard. For example, the following SQL statement could not be entered into the View Object Wizard:
    select key1, key2, SCORE(10),SCORE(20)
    from table1
    where contains (attrib1, 'apple', 10) >0 OR
    contains (attrib1, 'orange', 20) > 0
    Order by NVL(SCORE(10),0), NVL(SCORE(20),0);
    How can I embed the above SQL statement properly in a View Object? Or do I have to write SQLJ code outside of a View Object?

    As you mentioned BC4J gives the flexibility of using all valid SQL statements.
    For you query above, you would have to do the following.
    You would need to create caluclated attributes for SCore(10) and score(20)
    Select the ViewObject in Navigator and edit it (right mouse button)
    Select Attributes Tab
    Click on New attribute Score(10) and you can give an alias name for that.
    same goes for score(20) also.
    Select query tab now
    Choose expert mode check box
    Paste your query in the text box
    and Orderby clause in the orderby textbox
    click on the test button to test it
    raghu

  • To find 2nd highest salary in employee table

    Hi,
    I want to know how to calculate the 2nd highest salaried employee details.
    rownum "=" sign cannot be used i suppose and
    with and without using orderby clause.
    both the methods needed.
    cheers,

    With order by
    select * from
       ( select q.*, rownum as rn from
          ( select * from emp order by sal desc ) q
    where rn=2
    /With analytics:
    select empno , sal
    from ( select empno , sal
                  , dense_rank () over (order by sal desc) as sal_rank
           from emp )
    where sal_rank = 2Notice that DENSE_RANK() might give us a different result compared to RANK() and both give us a different result from the first example.
    Cheers, APC

Maybe you are looking for