Can i assign an 'order by' clause dynamically in forms ??

I know it's possible to assign an 'order by' clause in reports with lexical parameter.
for example..
select A
from TABLE
where A is not null
&V_ORDERBY
In this, v_orderby might be 'order by name' like that,,,
can i assign an 'order by' clause dynamically IN FORMS ??
If you understan my question, please answer to me,,,ㅜㅜ

Have you tried this build-in function?
SET_BLOCK_PROPERTY('[BLOCK_NAME]', ORDER_BY, 'SORTCOL1, SORTCOL2...');
Where 'SORTCOL1, SORTCOL2...' are the table columns name.

Similar Messages

  • Order by clause  Dynamic in Oracle function

    How can i get order by Clause Dynamic in Oracle function
    My function Returns sql query with SYS_REFCURSOR . and i will pass the order by column as input parameter
      create or replace
    FUNCTION TEST_SSK
            p_srot  number
    RETURN SYS_REFCURSOR
    AS
    C_testssk SYS_REFCURSOR;
    BEGIN
    OPEN C_TESTSSK FOR
    SELECT LOAN_CODE,LOAN_DATE,DUE_DATE,LOAN_AMT FROM LOAN_MASTER
    order by P_SROT;
    return C_testssk;
    end;Edited by: user10736825 on Dec 22, 2010 11:34 AM

    you can go for a dynamic query ;)
    create or replace
    FUNCTION TEST_SSK
            p_srot  number
    RETURN SYS_REFCURSOR
    AS
    C_testssk SYS_REFCURSOR;
    l_str VARCHAR2(4000);
    l_order VARCHAR2(100);
    BEGIN
    l_str := 'SELECT LOAN_CODE,LOAN_DATE,DUE_DATE,LOAN_AMT FROM LOAN_MASTER ';
    IF p_sort = 'LC'
    THEN
      l_order := ' ORDER BY LOAN_CODE ';
    ELSIF p_sort = 'LD'
    THEN
      l_order := ' ORDER BY LOAN_DATE ';
    END IF;
      l_str := l_str || l_order ;
    OPEN C_TESTSSK FOR l_str;
    return C_testssk;
    end;

  • Query can't include an "ORDER BY" clause when having column heading sorting

    I'm getting the following error when I try to include "ORDER BY" in my sql statement :
    "Your query can't include an "ORDER BY" clause when having column heading sorting enabled"
    I have used other sql statements with "ORDER BY" but this is the first time I have come across this and I don't understand why it's going wrong. Does anyone have a suggestion as to how I could fix it? Here is one of the sql statements which I have tried which is giving me the error:
    select "ID_NUMBER",
    "PROJECT_NAME",
    "PROJECT_TYPE",
    "OWNER",
    "PRIORITY",
    "STATUS",
    "END_DATE",
    "COMMENTS"
    from "PROJECT"
    WHERE "STATUS" != 'Completed' AND "STATUS" != 'Cancelled'
    ORDER BY "END_DATE"
    Regards,
    Ed.

    You must deselect column heading sorting that is in the page "Report Attributes" .This is a check box placed on the same line of the element of the report.
    bye

  • How to make an ORDER BY clause dynamic

    is there anyway to make the ORDER BY clause in an SQL query within a DB control
    dynamic? I have tried to pass a String of the column name and place it in the
    statement within {}, but it doesn't work

    "Mark" <[email protected]> wrote:
    >
    is there anyway to make the ORDER BY clause in an SQL query within a
    DB control
    dynamic? I have tried to pass a String of the column name and place
    it in the
    statement within {}, but it doesn't workDid you find how ? please let me know, I also need to have a dynamic order by
    clause.

  • Why I cannot use RowID in where clause but can use it in order by clause

    I am on SQL Server 2008.
    1. If I use
    SELECT (ROW_NUMBER()  over
    (order by ImportId, ScenarioId, SiteID, AssetID, LocalSKUID, WEEKID, MonthID)) RowID, * 
      FROM [JnJ_Version1].[dbo].[td_Production_Week]
      order by RowID
    Statement works
    But
    2. If I use
    SELECT (ROW_NUMBER()  over
    (order by ImportId, ScenarioId, SiteID, AssetID, LocalSKUID, WEEKID, MonthID)) RowID, * 
      FROM [JnJ_Version1].[dbo].[td_Production_Week]
      where  RowID > 10000
    I get error, RowID is an invalid column Name why? How to correct query 2.

    This is due to the logical evaluation order of a SELECT statement. Logically, a SELECT statement is computed in the order:
    FROM (which includes JOIN)
    WHERE
    GROUP BY
    HAVING
    SELECT
    ORDER BY
    OFFSET
    Thus, you can use what is defined in the SELECT list in the ORDER BY clause, but not in the WHERE clause.
    In the case of row_number(), this has immediate repurcussions. row_number() is computed from the rows as they arrive the SELECT clause, and if you then you would filter on the value in the WHERE clause you would be going round in circles.
    To do what you are looking for, you use a nested table, for instance with a CTE:
    WITH numbering AS (
       SELECT (ROW_NUMBER()  over
    (order by ImportId, ScenarioId, SiteID, AssetID, LocalSKUID, WEEKID, MonthID)) RowID, * 
      FROM [JnJ_Version1].[dbo].[td_Production_Week]
    SELECT *
    FROM   numbering
    WHERE  RowID > 10000
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Sorting character column ( used in order by clause dynamically)

    Hi,
    I need help on sorting character-based numbers. Like say, I want to sort customers based on street numbers(which is a character string being used in the
    order by clause) they live in.
    The criteria are :
    i. Numbers must take precedence.
    This being a character string, 1000001 comes before 2. This shouldn't happen. And you cannot use to_number
    since using it with a string having characters in it would raise an error.
    ii. If only a single alphabet occurs as the last character, then treat the whole string as a number except the last character and then sort it
    as if sorting a number. Something like : if you have 1000A, 200D, 200B, 1000X, the result would be 200B,200D,1000A,1000X.
    iii. if a character occurs elsewhere in the string, then perform the search normally as if performing a character search.
    The output of the following data :
    100
    A101
    B100A
    110C
    C120B
    120
    100020
    120C
    C1100
    100D
    would be like :
    100
    100D
    110C
    120
    120C
    100020
    A101
    B100A
    C120B
    C1100
    Please note that the sort is being done dynamically, so I could have access to the values of the street numbers only during run time.
    Any help is really appreciated.
    Thanks in advance.
    Regards,
    Anil.

    Create a function to test whether the column is numeric :
    create FUNCTION is_numeric(v_number VARCHAR2)
    RETURN INTEGER
    IS
    l_number NUMBER;
    BEGIN
    IF INSTR(UPPER(v_number),'E') > 0 THEN
    RETURN 0;
    END IF;
    l_number := TO_NUMBER(v_number);
    RETURN 1;
    EXCEPTION
    WHEN OTHERS THEN
    RETURN 0;
    END;
    And try this query
    Assume the table name is TEST with column STREET
    select * from TEST
    order by case is_numeric(STREET) when 1 then LPAD(STREET,20, ' ') else STREET end
    Please make sure that 20 mentioned above is the column size for STREET.
    Hope this helps.
    -Nags

  • How to use "Order by" clause dynamically on LOV values in 10g r2 forms

    Hi ,
    I have following requirement,please guide me.
    1 Create a List Of Values with 2 fields, Code and Description
    2. Do not use order by clause in record Group Query
    3. Attach this LOV to a field in Form
    4. When user invokes the LOV user will see two fields in LOV with header as Code and Description
    5. Now when user clicks on Column Header “Code” then LOV should be sorted on Code
    6. And if User clicks on Column Header “Description” then LOV should be sorted on Description
    Thanks in Advance.

    Kindly post this problem in this forum ->
    [Forms Forum|http://forums.oracle.com/forums/forum.jspa?forumID=82]
    And, close this thread by marked it as answered. ;)
    Regards.
    Satyaki De.

  • Order by clause -dyamically in Forms

    I am using Forms 6i. I want to do Forms to Excel stuff and I am doing this by opening a cursor and then start Excel routine using OLE2.
    The user will select the 'order by' columns from a list-field in the form.
    Problem is I have given Order by clause as given below sample, but it just don't work..
    How to accomplish this ??
    declare
    Cursor emp_cursor is
    SELECT code,name,dept,desig,salary
    FROM emp
    order by :s1,:s2;
    begin
    -- excel routine
    end;

    Hi vdsk,
    Here is link to create_group_from_query built_in:
    http://www.oracle.com/webapps/online-help/forms/10g/state?navSetId=_&navId=3&vtTopicFile=f1_help/builta_c/creategp.html&vtTopicId=
    you can prepare your select statement and then concatenate with order by clause. I think that is the best soultion for you.
    Regards
    Jakub

  • Can we assign process order in MB21 RESEVATION for extra material

    Sir,
    in Production sometimes we required extra raw material but already we issues raw material against  process order then that time where we assign extra raw material in process order or where we check costing of extra material qnty aginst process order.
         can we asssign extra material against process order in MB21 with movement type 261

    Dear,
    It is not possible to create the manual reservation against the order for 261 movement type. Because system generate the automatic reservation for an order whcih can not be modified. Better you go for component or operation scarp to plan the extra requirement. MB21 you create the reservation with 311 movement here you give reference of an order also maintain the long text for same. By this you can transfer the extra consumption from main storage location to production storage location. And issue material against the order with MB1A 261 against the oder as unplanned consumption.
    Hope clear to you.
    Regards,
    R.Brahmankar

  • Order by clause dynamic

    Hello,
    I created a radio button to sort the data in the form.
    STATIC2:Date Asc;1, Date Desc;2, Activity;3
    The data is only sorted by date asc and activity asc. The sort by date desc didn't work.
    ORDER BY DECODE(:P20010100_SORT,1,to_char(ENTRY_DT,'dd/mm/yyyy')|| 'Asc',2,to_char(ENTRY_DT,'dd/mm/yyyy')|| 'Desc',3,ACT_ID || 'Asc',to_char(entry_dt,'dd/mm/yyyy')|| 'Asc')
    Do you have an idea how to do it ?
    Thanks in advance

    You cant do order bys with ASC / DESC unless you dynamic sql or some trickery.
    For example:
    Make columns that reverse the values for you so that you are always sorting ASC.
    order by decode(:somevar,
    1,created,
    2,to_date('01-jan-2999','dd-mon-yyyy')-(created))

  • Dynamic ORDER BY clause

    Hi all,
    I'm creating a webpage using jsp thats accessing a mysql database. When I get a ResultSet from a query, I was wondering if anyone could give me some pointers on how I could sort the results based on a field name that someone clicks on. For example:
    Column1   Column2
    5         2
    8         1
    3         6I'd like to create hyperlinks on the field names so when a user clicks on it, it will sort the data in according to that field. Here is my code that I am trying to modify:
    public String displayResultSet(ResultSet rs)
    {// return a result set as an html table
         String htmlTable = "";
         try {
              // get the number of columns
              ResultSetMetaData rsmd = rs.getMetaData();
              int numColumns = rsmd.getColumnCount();
              // create a table and display the mysql field names as table headers
              htmlTable += "<TABLE>\n<TR>\n";
              for(int i=1; i<=numColumns; i++)
                   htmlTable += "<TH>" + rsmd.getColumnName(i) + "</TH>\n";
              htmlTable += "</TR>\n\n";
              // create an object to temporarily hold a piece of ResultSet data
              Object cellData = null;
              // display the data in the ResultSet in rows of an html table
              while(rs.next())
              {// while the ResultSet has more rows, convert them to html
                   htmlTable += "<TR>";
                   for(int j=1; j<=numColumns; j++)
                   {// if the data is not null, display it, otherwise display a blank space
                        cellData = rs.getObject(j);
                        if(cellData != null)
                             htmlTable += "<TD>" + rs.getObject(j) + "</TD>\n";
                        else
                             htmlTable += "<TD> </TD>\n";
                   htmlTable += "</TR>\n\n";
              htmlTable += "</TABLE>\n\n";
         catch (Exception e)
              { return("Error accessing database: " + e); }
         return htmlTable;
    }Any help or references to where I can read up on it would be appreciated. Thanks
    Leon

    Your display code should not be mixed in with your database code. That functionality should be seperated classes.
    Generally GUIs do the ordering themselves. They do not repeatedly call the database.
    But if you want you pass in a descriptor that defines the fields that will be ordered on. You optionally map that to the exact database field names. You then use StringBuilder to construct the entire SQL string and add the order by clause dynamically at the end. Then you execute it.

  • Order By Clause in View

    Hi,
    I have a doubt regarding Order By Clause in Views.
    As per my knowledge, we can't put an order by clause in the subquery that defines view. But when i created a view in Oracle 9i with the order by clause, view got created.
    Please see the my view code below :
    create or replace view testview
    as select * from employees
    order by 1,2;
    Could anyone please confirm that we can have order by clause in Views in oracle 9i?
    Thanks,
    Tandra

    According to the SQL Reference doc, there is no such restriction for a non-updatable view:
    The view subquery cannot select the CURRVAL or NEXTVAL pseudocolumns.
    If the view subquery selects the ROWID, ROWNUM, or LEVEL pseudocolumns, those columns must have aliases in the view subquery.
    If the view subquery uses an asterisk (*) to select all columns of a table, and you later add new columns to the table, the view will not contain those columns until you re-create the view by issuing a CREATE OR REPLACE VIEW statement.
    For object views, the number of elements in the view subquery select list must be the same as the number of top-level attributes for the object type. The datatype of each of the selecting elements must be the same as the corresponding top-level attribute.
    You cannot specify the SAMPLE clause.
    This restriction exists only for updatable views:
    If you want the view to be inherently updatable, it must not contain any of the following constructs:
    A set operator
    A DISTINCT operator
    An aggregate or analytic function
    A GROUP BY, ORDER BY, CONNECT BY, or START WITH clause
    A collection expression in a SELECT list
    A subquery in a SELECT list
    Joins (with some exceptions as described in the paragraphs that follow).

  • SQL Query rewrite, remove ORDER BY clause

    Hello,
    we've just installed a proprietary application which uses an Oracle 11.2.0.2 RAC database. We've seen that one of the auto-generated application's queries
    has poor performance (3-5 minutes for results), the query does a SELECT and at the end it uses an ORDER BY clause. If we remove the ORDER BY clause
    the query returns the results in less than 5 seconds. Unfortunately, we can't re-write the query in the application since we don't have any access to it and
    i was wondering if there is a way to rewrite the specific query from the database.
    We've already seen the SQL Patch but we can change only the hints of the query so we can't remove the ORDER BY clause from it. From what we've seen
    outlines also change only the hints and not the actual sql statement.
    Is there a way to rewrite the specific query from the database ?
    thanks in advance,
    Giannis

    Maybe DBMS_ADVANCED_REWRITE can help but this a SQL question than has very likely nothing to do with RAC.
    See http://www.oracle-base.com/articles/10g/dbms_advanced_rewrite.php.

  • ViewObjects Order by clause with DECODE

    Hello!
    I am using Jdeveloper 11g, version 11.1.1.2.0.
    The problem I'm having is this.
    If I use a DECODE statement in view objects ORDER BY clause, I get an error: "java.util.regex.PatternSyntaxException: Unmatched closing ')' near index 2".
    Let me give an example. I'll be using EmployeesView view object, which is using Employees entity from HR schema.
    This is a part of view objects XML.
    <ViewObject
    xmlns="http://xmlns.oracle.com/bc4j"
    Name="EmployeesView"
    Version="11.1.1.55.36"
    SelectList="Employees.EMPLOYEE_ID,
    Employees.FIRST_NAME,
    Employees.LAST_NAME,
    Employees.EMAIL,
    Employees.PHONE_NUMBER,
    Employees.HIRE_DATE,
    Employees.JOB_ID,
    Employees.SALARY,
    Employees.COMMISSION_PCT,
    Employees.MANAGER_ID,
    Employees.DEPARTMENT_ID"
    FromList="EMPLOYEES Employees"
    BindingStyle="OracleName"
    CustomQuery="false"
    PageIterMode="Full"
    UseGlueCode="false"
    OrderBy="Employees.MANAGER_ID">
    As you can see in this case, the Order by clause is very simple. This works like a charm.
    But, if put something like this "DECODE(Employees.MANAGER_ID, NULL, 1, 2)" in the Order by, I get an internal parsing error.
    I replicated this error on my home machine as well as on my work machine. I'm using the same version of Jdeveloper on both.
    Has anyone else stumbled upon this problem and solved it?
    Any thoughts would be greatly appreciated :)
    Kristjan

    The second example works, but the first one doesn't, unfortunately :/
    Also, the example I gave is unfortunately just that, a proof-of-concept example that there is a problem with DECODE if it is written inside the Order by clause.
    My real DECODE use case is a bit different. Like this: "DECODE(attribute, 'N', 1, 2) ASC".
    Since posting my original question, I did some research-by-example work and I discovered that this is not just a problem of DECODE, but more like a problem of brackets and commas.
    No database function that uses more than one parameter can be used in Order by clause.
    The reason is, if a function with more than one parameter is used, commas inside brackets have to be used. Something along the lines of: "database_function(param1, param2, ...)".
    The parser seems to have a problem with this kind of expressions.
    Is there a work around?
    Kristjan
    p.s.: Thank you for your quick response.

  • 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

Maybe you are looking for

  • HT2452 I need to create a New Apple ID for my wife

    I need to change my Apple ID

  • Return 1st gen time capsule?

    I have a first generation time capsule that despite my best efforts, refuses to work. I read on the site timecapsuledead.org that its because it over heats. It also states that you can make Apple replace it by calling them. However, the site was upda

  • Export save pdf presets inside pdf file

    With distiller you have an option called "save adobe pdf settings inside pdf file", so as receiver of such a pdf file you can detect which settings are used for creating the pdf file. Is there also such an option in Indesign so you can detect which s

  • Error code 2 Creative Cloud

    I just wanted to update creative cloud and this error came up has anyone experienced this? PC Specs Model: ASUS Notebook UL50VT Processor: U7300 @ 1.3GHz RAM: 4GB OS: WINDOWS 7 64bit

  • Install Edge on different drive

    I have a small SSD for my C: (OS) drive, so I install all of my software on my D: drive.  In Creative Cloud -> Preferences -> Apps  I have the install location set as:  D:\Program Files\Adobe CS It works for most of the apps, but the Edge apps still