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.

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;

  • How to make an order on repeating frame using Formula Column?

    Hi All,
    I have a repeating frame dependent on some query, how to make an order on this repeating frame using a formula column defined in its group and dependet on values from the query?
    Note: I'm using Reports 6i

    Place your formula column at the top of the itm group and set the BREAK_ORDER to assc.. or desc...
    Hope this helps
    Hamid
    if problem solved, close the thread.

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

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

  • 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 make an 'order' button that works?

    How do I make an 'order' button, by clicking on it, will post a pre-defined product number in a contactform?
    Probably I have to use php, but I do not know how to make the correct script.
    Regards, Gerald

    If you just need it to pop text into a textfield, you can use javascript, something like this might do the trick for you...
    <textarea id="TheText"></textarea>
    <select id="DropDown">
        <option value="">None</option>
        <option value="text-one">Choice One</option>
        <option value="text-two">Choice Two</option>
        <option value="text-three">Choice Three</option>
        <option value="text-four">Choice Four</option>
    </select>
    <script type="text/javascript">
        var thetextbox = document.getElementById('TheText');
        var mydropdown = document.getElementById('DropDown');
        mydropdown.onchange = function(){
        thetextbox.value = this.value;
    </script>
    The script should come after the textbox and dropdown in your HTML.

  • How to make the title of screen dynamic in ABAP.

    Hi experts,
    I want to make the title of screen dynamic like:-
    --> i have an initial screen in which program takes some input files..and having a screen title as "INPUT FILE" with a read button.
    --> after clicking on read button it reads that file and shows on screen that exel file...here this screen title remains the same as "INPUT FILE" but i want it as "READ FILE". now this screen again having a button as write file.
    -- > Now after clicking on this write button this file gets write in to SAP system here i want my screen title as"WRITTEN FILE".
    Please help me and tell me the way to do it.
    Regards,
    Depque.

    Hi.
    Ypu should use a flag as soon as someone clic on the button, in order to keep a value.
    Then in PBO Module you should ask for the value of this flag
    if w_flag = abap_true ('X')
    set tittlebar number01.
    else.
    set titlebar number02.
    endif.
    Please let us to know if this could help you.
    Regards,
    Gabriela

  • How to change the order by clause of a standard VO in OAF

    Hi All,
          I need to change only the order by clause of a standard VO (Which is attached to a messageChoice item).
    Steps followed:
    1)Created a custom VO by extending the standard VO .
    2)VO Impl class files are not generated as seeded VO has no such class files.
    3)Created a substitution
    4)Imported it
    5)When I try access the specific page, getting Sys Admin error without any clue about the error.
    Even I tried to create the custom VO without extending the std VO ,
    Still getting the same error .
    Please provide your suggestions on this.
    Thanks,
    Thavam

    When I set the FND:Diagnostics profile option , I could see what was the exact error . It was SQL Wrapper exception error.
    The VO which is extended , has a dynamic where clause with bind variables. The binding style of the extended VO does not match with seeded VO. It works when the binding style is changed.
    Thanks,
    Thavam

  • How to make deployment order irrelevant

    Right now I have 2 SOA projects, A and B. A calls B. I have to deploy B first, then A second. Otherwise if I deploy A before B then when I run A, I will get an error saying it can't find B.
    Is there a way to make deployment order not important so we can deploy SOA projects in any order we want? In my example, I can deploy A or B in any order I want.
    Thanks

    Hi,
    Thanks for the response.
    I have already attached the shipping, production and warehouse calendar and also the transportation calendar in the means of transport in the transportaion lane.
    But it still does not consider factory calendar. It does not take weekend and the holidays into account for deployment purpose.

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

  • How to make columns in a table dynamic

    Hi,
    I want to make the columns of a table dynamic.
    At design time I dont know how many columns will be required.
    Rows are made dynamic by using the bean concept.
    Please help me in this reference(columns).
    Thanks
    Pooja

    Hi, i don't know how you create the rows dynamically but
    have you tried to use a forEach?
    <af:table ...>
    <af:forEach items="..." var="...">
    <af:column headerText="...">
    <af:outputText value="..."/>
    </af:column>
    </af:forEach>
    </af:table>
    here there is an example of a dynamic panelList:
    <af:panelList rows="3" maxColumns="6">
    <af:forEach items="#{bindings.ContratosView1.rangeSet}" var="li">
    <af:commandLink text="#{li.Codigo}" action="Edit"/>
    </af:forEach>
    </af:panelList>

  • How to make Field "Period/Fiscal Year" dynamic in the program variant

    HI All,
    We have program called "RCRM_FM_ACL_ACCRUAL_RUN" which is used to calcukate accruals in CRM. This program has got a field "Period/Fiscal Year".
    We want this program to run every day at specific time. So we have created a variant in order to schedule a job with program so that it runs every day and calculates the accrual.
    when we create variant we need to maintain some values in the variant like fund plan id in fund plan id field and period/year in  "Period/Fiscal Year". Normally for date field we have an option to make a field dynamic by selecting value "D" (Dynamic) in selection variable, so it takes date every time as current date automatically and we do not have to change it every day.
    But in program *"RCRM_FM_ACL_ACCRUAL_RUN",* I could not find the option "D" for the field "Period/Fiscal Year". Because of this we have to change the "Period/Fiscal Year" manually every time when ever period/year gets changed. we want this to be done automatically.
    Can any onet tell me why we are not able to find the optin "D" (Dynamic) in the program "RCRM_FM_ACL_ACCRUAL_RUN". Do we need to do any settings for that.
    or
    Is there any other way to full fill my requirement i.e period/year get updated automatically with current period/year every time when period/year gets changed.
    Thanks in advance,
    JM.

    Hi,
    Using function-modules "RS_VARIANT_CONTENTS" and RS_CHANGE_CREATED_VARIANT and table tvarvc, you can make your variant dynamic. You just need to write a small piece of code using these FMs.

  • How to make components appear and disappear dynamically.

    So I admit I am from the HTML world and have been able to
    dynamically control divs to make them visible and invisible, as
    needed. How do you do that in Flex/Flash?
    I have tried the "visible" attribute, but the component takes
    up the same space when invisible leaving a big hole in the page --
    very surprising. I have changed the height and width to zero (which
    works) but have not been able to restore the size (since I want it
    to be width=100% and it is expecting a number, not percentage.
    So how do you implement hidden divs in Flex.
    Thanks.
    Mike

    In Flex, there is a separation between "is this component
    visible" vs. "does this component take screen space." Similar to
    the difference in CSS between "mydiv.style.visibility = 'hidden'"
    and "mydiv.style.display = 'none'".
    In Flex:
    // make it invisible
    mything.visible = false;
    // make it not take up space onscreen
    mything.includeInLayout = false;

  • How to change tables in from  clause dynamically

    Hi,
    I have to add some join conditions in where clause and tables in from clause based on some input parameters and data in other tables.
    How can i achieve this ? I must use procedure/function or dynamic query preparation or any more alternatives?
    Regards,
    Krishna

    Yes, you can use dynamic sql for that.
    But be aware that you'll be needing to concatenate the table names in your FROM-clause, you cannot bind them...
    So you'll be trashing the shared pool.
    Maybe alternative approaches are possible, but you provide too little input for my crystal ball here...

Maybe you are looking for

  • How can i remove services from the transient name service?

    hello all.. i am using the transient name service and i would like to remove a service if a server goes down...how can i do that?

  • How to install AIR 3.6 SDK in FB 4.7 without breaking iOS apps

    i downloaded the the Air 3.6 SDK with compiler from the labs website, unpacked it on mac, put the contents into the AIRSDK folder under the com.adobe.flash.compiler... folder as specified.  relaunch FB 4.7, and it shows that the AIR SDK is now 3.6. 

  • How do I delete calendar on iCloud?

    My calendar on iCloud is not correct.  I would like to delete the iCloud version and merge the corrected calendar to iCloud.  I could not find an option to delete on iCloud.  Any help appreciated.

  • Can you disable the SSID broadcast without turning off WIFI?

    Is there a way to disable the SSID broadcast without disabling WIFI altogether? Prior to the 4.3 IOS upgrade I could keep my WIFI enabled and when at home, the phone would automatically switch to my hi speed WIFI. The new upgrade now turns your phone

  • Problem removing LDAP binding

    Hello, When we set up our 10.6 server we did not know about the message it broadcasts offering to give "services" to clients, ie bind them to LDAP. Last fall several of our boarding students chose this option on their personal macs and they got our s