User constructed query using dropdowns

Hi all,
I am trying to create a sql query using select lists with an application page. My problem is that written as a statement it would say;
select count (distinct id)
from requests
where date_raised between '01 JUN 07' and '30 JUN 07';
but if try to have a select list passing 'date_raised' or 'date_closed' it still works but if I put another for 'between' and 'not between' it has a problem, for example;
select count (distinct id)
from requests
where :P5_SL_RAISED_CLOSED :P5_SL_BETWEEN :P5_START_DATE and :P5_END_DATE
and date_closed is null or date_closed >:P5_END_DATE;
Could someone help me please, I searched the forums and nobody seems to have done this. (Or maybe it's so simple they just didn't post!)
Thanks,
Jay

Hi Jay,
you can accomplish this in following way:
change your report type to SQL Query(PL/SQL function body returning SQL Query),
then in region source try this:
begin
return 'select count (distinct id)
from requests where ' || :P5_SL_RAISED_CLOSED ||' '|| :P5_SL_BETWEEN || ' to_date('''|| :P5_START_DATE ||''',''DD-MM-YYYY'') AND to_date(''' || :P5_END_DATE || ''',''DD-MM-YYYY'') and date_closed is null or date_closed > to_date('''|| :P5_END_DATE || ''',''DD-MM-YYY'')';
end;
Of course, you should change DD-MM-YYYY to date format used in your fields.
Hope this helps.
Tomasz K>

Similar Messages

  • Filter query with sub query using Dropdown box

    Dear Community,
    I have 2 queries
    1. Main Query with 2 fields:  Project | Project value
    2. Sub Query with 2 fields:  Project group | Project
    Project group can be belonging to number of projects and project can be belong to number of project group (Many to Many).
    My customer wants the main query will open without any filtering.
    When I choose project group from WAD dropdown box, the main query will filtering all the projects that belong to the project group.
    I create WAD; define dropdown box as sub query, and Analysis as main query.
    In the dropdown box I choose "data binding" char and create command "set selection state by binding" (project to project) but it doesnu2019t work. 
    I also try to do this by Replacement Path in the main query, but the variable requires the attribute will be ready for input.
    Thanks a lot
    Yaniv

    I am not sure about your comments on replacement path variable. Without having tried it, here is what I would have attempted:
    The main query needs to use a replacement path variable for Project that is replaced by the results of the sub-query. Sub-query would have a regular input variable for project group. (as a quick test, if you had one analysis item for main query with variable input enabled, it should prompt you to enter Project group).
    Now the drop-down needs to be associated with a javascript function. The javascript function needs to implement command "Set variable state" for the main query data provider to selected value of the drop-down.
    The drop-down should be associated with the sub-query data provider, just used to populate the list of values in drop-down.

  • CANT execute query with parameter on user defined tables using query genera

    Dear All,
    I have problem when executing query with parameter on user defined tables using query generator.
    It seems SBO cannot accept parameter to query user defined tables.
    I've tried these:
    SELECT T0.U_Status FROM [@ST_PR_H] T0 WHERE T0.U_Status = [%0] --- this FAIL
    I try to pass the value directly without using parameter and It works
    SELECT T0.U_Status FROM [@ST_PR_H] T0 WHERE T0.U_Status = 2 --- this SUCCESS
    This one works
    SELECT * FROM RDOC T0 WHERE T0.width =[%0]  --- this SUCCESS
    and this one works too
    SELECT * FROM RDOC T0 WHERE T0.width = 595  --- this SUCCESS
    Is there anyone can help me ....???
    Thanks,
    Alfa

    I  generated this code using query wizard ....
    SELECT T0.[U_Status] AS 'Document Status' FROM  [dbo].[@ST_PR_H] T0  WHERE T0.[U_Status] = (N'2' )
    and replaced the (N'2' ) with [%0]
    SELECT T0.[U_Status] AS 'Document Status' FROM  [dbo].[@ST_PR_H] T0  WHERE T0.[U_Status] = [%0]
    and It worked ......
    Thanks 4 all .....

  • How to find whether user exits are  used in the query or not??

    Hi ,
    I have to make the list of queris in which user exits are used.
    Please any body help me how to find the queries in which user exits are used.
    Thanks
    Maruthi

    Hi Maruthi,
    Using table RSZGLOBV you can find out the queries that have customer exit variables.
    Set filter VRPROCTP (processing type) = 3 means customer exit.
    and the field COMPID will give you the Query name.
    Best Wishes,
    Mayank

  • Can I run a User Query using SDK?

    Hi I am new to SDK development.
    Can I run a user query using SDK?  what I am after is, when the user clicks a button on my screen, I want to run the user query already in the system.
    If this can be done, does anyone know how to do this? I have not been able to find a way of doing this so far. appreciate any help here.
    Thanks,
    Indika.

    Hi,
    I have an additional question to this thread. Does anyone know a way how to run an user query, and how to pass some parameters to it, so the user doesn't have to write them down manually?
    For example, I add a button on a Bussines partner form and when this button is clicked, I want a query to be started with parameter %1 = businnes partner's code...
    Is there some way how can I do this?
    Thanks
    Bohous

  • Make a users not to use schema prefix in a query

    Hello,
    I created a user who has a default tablespace name "USERS", apparently this user need to query tables from another schema, as a result this user need to use the schema prefix to query this table. Now, how can i create the user such that this user does not need to key in schema prefix before querying the table in this schema. Please help
    thx
    Sam

    Hi,
    I can see 2 choices:
    1/ create SYNONYMs for objects in the target schema. This will allow you to use the synonym for the object. Check in TFM for more infos about SYNONYMs.
    2/ use an after logon trigger to define which is the current schema in the session (ALTER SESSION SET CURRENT_SCHEMA=xxx). Note that if you do that, you'll need to prefix the tables of the user if you want to acces them.
    Regards,
    Yoann.

  • How to use user defined function in select query using Toplink

    Hi Friends
    I am little bit of new in Toplink stuff... so please help me...
    I have to database functions 1. encrypt and 2. decrypt.
    I want to exceute the following sql query using toplink
    select port, database, user_name, decrypt(encrypt('String which is to be encrypt ','password'),'password') from CONFIGURATION
    can anyone tell me , how to write code in toplink which will give the about sql output.
    thanks .....

    The "Specifying a Custom SQL String in a DatabaseQuery" section in the TopLink Developer's Guide may help... http://download-uk.oracle.com/docs/cd/B32110_01/web.1013/b28218/qrybas.htm#BCFHDHBG

  • AE 5.2: Using user groups as a dropdown function

    Hi All
    We would like to use the user group functionality on CUP but the client does not have the same user groups across all systems.
    Our suggestion is that they have all user groups defined across all the systems.
    Is there a way that we could accomodate the client as per the current set-up where not all user groups are defined on all systems?
    Any assistance on this matter will be appreciated.

    Hi,
    I'm not sure of all the complexities around this but we had a similar problem where the user respository we used could not be connected using LDAP.
    The solution that was implemented was to create an ADAM (Active Directory Application Mode) directory, which is connected to the user repository - ADAM is then connected the UME for AE as the LDAP server.
    Probably not the most elegant solution, but we have been using this in  PRD environment for a couple of months now without any performance issues.
    Unfortunately I don't have all the details to guide you through all the config that was required, but perhaps you could investigate this as an alternative solution.
    Regards

  • Error while accessing Query using Query Analyzer

    dear experts...
    while accesiing the query using query analayzer...
    we are getting below error...
    What has happened?
    URL http://xxx.xxx.xxx.xx:XXXX/irj/servlet/prt/portal/prtroot/pcd!3aportal_content!2fcom.sap.pct!2fplatform_add_ons!2fcom.sap.ip.bi!2fiViews!2fcom.sap.ip.bi.bex call was terminated because the corresponding service is not available.
    Note
    The termination occurred in system BI1 with error code 404 and for the reason Not found.
    The selected virtual host was 0 .
    What can I do?
    Please select a valid URL.
    If you do not yet have a user ID, contact your system administrator.
    ErrorCode:ICF-NF-http-c:001-u:ANAND-l:E-i:PSRCCPRDA003_BI1_00-v:0-s:404-r:Notfound
    HTTP 404 - Not found
    Your SAP Internet Communication Framework Team
    thanks for helping me...
    anand

    Hi friends,,
    instead of getting the link like
    http://128.222.125.57:9000/sap/bw/bex?cmd=ldoc&infocube=ZMC_SRH1&query=AGINGV21A&sap-language=EN(working link)
    am getting below link...which is getting an error....
    http://128.222.125.57:9000/sap/bw/://:/irj/servlet/prt/portal/prtroot/pcd!3aportal_content!2fcom.sap.pct!2fplatform_add_ons!2fcom.sap.ip.bi!2fiViews!2fcom.sap.ip.bi.bex?QUERY=AGINGV21A
    above marked is the unwanted thing so how can i change my link in query designer???
    please suggest me firneds

  • How do i know if my query using  SORT_AREA_SIZE   or temporary tablespace ?

    Good Morning  Everyone !
    My DB version is 10.2.0.1
    I have large table  exactly 3 million records.
    SQL> select count(*) from tab1;
    COUNT(*)
       300000
    SQL> select * from tab1 order by no DESC;
    sorting  ... in process
    300000 rows selected.
    in Terminal 2 : I tried to find  sorting details -   ( No rows  selected - why ? )
    SQL> select USERNAME , USER , TABLESPACE , SQL_ID from v$tempseg_usage  ;
    no rows selected
    SQL> /
    no rows selected
    When i google i have seen this ;
    If  Oracle cannot do the sort in memory  (SORT_AREA_SIZE initialisation parameter), space will be allocated in a temporary tablespace for doing the sort operation.
    REF_LINK : TEMPORARY Tablespaces and TEMPFILES | Oracle FAQ
    MY DOUBT QUESTION :   How do i know if my query using  SORT_AREA_SIZE   or temporary tablespace ?
    Thanks in advance.

    @ JohnWatson
    I have seen some articles from ORA - FAQ. Good.
    SQL> select USERNAME , USER , TABLESPACE , SQL_ID from v$tempseg_usage;
    USERNAME                       USER   TABLESPACE                      SQL_ID
       SCOTT                               SYS          TEMP                            fh9vqgyd6m0d1
    PGA management means that sorting only 300000 rows  may well occur in memory
                Is this (3 million rows) -  standard  value for 10g version ?
    Thanks JohnWatson

  • SAP / ABAP Query - using logical database

    Hi ,
    We have a mandate to implement SAP Query using only Logical Databases (LDB ) .
    We understand that there are several issues using this approach .
    1 ) Paralled tables in MM need to be displayed on separate lines .
    2 ) Statistics based on fields from 2 different tables cannot be produced eg: EKPO ( PO Number )  and EKKN . (Cost Center )
    Please share your experiences .
    Thank you in advance .
    Kishore
    Kishore

    Adeel,
    I do appreciate your experience and respect you for knowledge on SAP Query. 
    Joining tables seem simple to IT experts but not so for end users.  SAP Query is an end-user tool and users seem to need a simple user-friend, drag-and-drop solution to extract information using SAP Query based on a pre-defined infoset.  Various SAP conferences have been advocating the use of SAP delivered Logical Databses to create infosets in order to harness the various advantages of LDBs. 
    In MM there are several LDBs (e.g. ELM, EBM etc) to create queries on EKPO and EKKN.  The problem arises when you use the same LDB to extract information from more than the above two tables e.g. EKPO, EKET, EKKN and EKBE.  SAP expects you to display fields on multiple lines and also does not allow producing statistics based on fields from two parallel tables say EKKN and EKBE.  Moreover, multi-line reports cannot be produced in the ALV/SLV format.  
    We are also looking for best practise solutions in providing SAP Query to MM or FI users based on SAP delivered Logical Databases.  
    Pascal

  • Pre-parsing user-entered query strings

    I'm looking for a robust PL/SQL (or other) script for pre-parsing user-entered query strings, so I can make intermedia work like familiar search engines. (Think Yahoo/Alta Vista.) It has to deal gracefully and intuitively with embedded special characters, boolean constructs, quoted literals, etc.
    Has Oracle released anything like this?

    There's example code in "The Button" download from http://technet.oracle.com/products/intermedia in the file "avquery.java".
    Putting the query directly into ABOUT() also works if you don't need to clean up end-user input.
    null

  • Need to skip the variable selection screen when using dropdown

    Hello Friends,
    I have created a web template having a dropdown, a table and a text element. Basically I am trying to follow the guide "How to Use a Dropdown Box to Set Variable Values". It shows how to select values for a variable using dropdown.
    NOTE: The guide can be found here:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/2642ab90-0201-0010-9193-d59de66cbab4
    What is happening is when I select a value for the variable in the dropdown, the correct url is getting formed but instead of displaying the report using the selected value, the variable selection screen appears. Given below is the url that gets formed:
    http://abcdev.wdf.sap-ag.de:8000/sap/bw/BEx?SAP-LANGUAGE=E&PAGENO=1&REQUEST_NO=3&CMD=PROCESS_VARIABLES&SUBCMD=VAR_SUBMIT&VAR_NAME_1=TSTPEROD&VAR_VALUE_EXT_1=04.2007
    Please assist me to get rid of the variable selection screen. Thanks!
    Regards,
    Prem.

    Hello Ray,
    Thanks for your reply. This has partially resovled the issue. I have awarded you points for that. Now I am able to skip the variable screen.
    However, the query results are not getting refreshed. I wanted to restirct the values based on the value given in the variable selection (In my case the dropdown box). Somehow I am not able to link the dropdown with the variable or the "SAPBWOpenURL(url);" function is having some issues.
    Please assist. Thanks!
    Regards,
    Prem.

  • Report Not apperaing in User's Query Report Viewer Menu

    Hello There!
    Continuing with below thread
    Report Category not Appearing in Report Definition
    When i search for a report i created, i'm(as a normal user) not able to find any report after searching.(assigned to me or to my role.)
    The view PSXPRPTSRCH_VW has two tables PSXPRPTDEFN and PSXPDATASRC .Both have oprid column which is blank and the above view's first where clause is asking for oprid.
    I don't understand how then all the doc./papers on internet i read, to create Report using XML Publisher says/shows the report appears in user menu(query report viewer). May be they still using PS login to show the output?
    Anybody have any idea where am going wrong?
    The category,datasource,Definition,query tree all set properly. Do user need any special role/permission assigned?
    BTW user can see the query report viewer menu.
    Regards!
    Edited by: user10569054 on Sep 27, 2012 2:32 PM
    Peoplesoft Version 9.00
    Database Oracle 10.2

    Thanks for the Reply.
    from the doc. you gave, this is what i found.
    Home > PeopleBooks > PeopleTools 8.52: BI Publisher for PeopleSoft > Running, Locating, and Viewing BI Publisher Reports
    The Query Report Viewer allows selection and online viewing of those reports that have a data source type of PeopleSoft Query. Existing Query security applies so that each user has access to run only the reports to which he or she has qualified Query access to the data source.
    The PS query and the data source is created by user PS then how can a normal user will have access to that?
    I'm bit confused here.
    Regards!

  • Query using where clause

    I am not able to run a SQL query using where clause.
    the query is as follows:
    I extract the text input by the user in a text field say 'a' and
    store it in string 'y'.
    String y= a.getText();
    //running the query
    Select A from B where B.x=y;
    how do we run a where clause when y is a string variable instead of value?

    Use the following :
    String y = a.getText();
    String query ="select A.CODE from Port A where A.NAME=" + "'" + y + "'" ;
    ResultSet rs= stmt.executeQuery(query);

Maybe you are looking for