Parameterized report based on mutually exclusive items

Hi guys,
if you visit :
http://apex.oracle.com/pls/apex/f?p=59187:1
you see that the Select List Item " Property_type" has few values based on which the rest of the items get rendered.
How Can I write a query to get the correct result based on the chosen values ????
In other words,
If the Value of the Item "P1_property_type" is 'Apartment' Then the Item "P1_beds" gets rendered and sould be considered in the query.
( the un-rendered items should be ignored in the query )
If the Value of the Item "P1_property_type" is 'Villa' Then the Item "P1_beds" does get rendered and sould not be considered in the query.
If the Value of the Item "P1_property_type" is 'Office' Then the Item "P1_beds" does not get rendered and sould not be considered in the query. But the Items "P1_Max_Sqft" and "P1_Min_Sqft" get rendered and should be considered in the query.
If the the Select Value items contain the default values then that should be similar to ( select * from srm ) except for if "P1_property_type" has its default value then the page should not be submitted.... ( there should be an alert )
Work Space: somefeto
User name: [email protected]
Password: Firas
App: 59187 ( the executive towers )
I hope my question is clear...& thanks for the help...
Regards,
Fateh

Fateh,
The short answer is yes this is possible but there are many ways to achieve this and I will offer you two of them.
1. Test for null or value
basically all you do is for every item rather than checking its value against the column you check to see if it is null or if it matches the value of a column this way this input has no effect on the query if it is null. This approach is fine for smaller datasets but maybe not the best for larger datasets. (of course this is always case by case)
select *
  from table
where (:item1 is null or
        column1 = :item1)
   and (:item2 is null or
        column2 = :item2)
   and (:item3 is null or
        column3 = :item3)2. function returning query
If your inputs have a value then add them to the predicate of your query. This can be encapsulated into a database package/function. we add the 1=1 as the first part of the predicate so it is easier to manage the "and"ing.
declare
  v_sql varchar2(32000);
begin
  v_sql := 'select * from table where 1=1 ';
  if :item1 is not null then
    v_sql := v_sql || 'and column1 = :item1 ';
  end if;
  if :item2 is not null then
    v_sql := v_sql || 'and column2 = :item2 ';
  end if;
  if :item3 is not null then
    v_sql := v_sql || 'and column3 = :item3 ';
  end if;
  return(v_sql);
end;These are not the only options out there but this should cover many situations. If you want to get really crazy you can create a sql type and return that from a pipelined function and cast that as a table. I would generally stick to one of these two options though :P.
Cheers,
Tyson Jouglet

Similar Messages

  • Report based on mutually exclusive items:

    Hi guys,
    I am trying to create a parameterized report based on mutually exclusive items:
    I have a Select List item "P1_Property_type" which has these values ( office , apartment ),
    if 'office' is chosen then the report should consider ONLY the value of the select list item "P1_beds"
    if 'apartment' is chosen then the report should consider ONLY the value of the select list "P1_size"
    I used this query, but it does not seem to wrok:
    select * from realestate where
    unit_type = decode (:P1_PROPERTY_TYPE,'null',unit_type,:P1_property_type)
    and
    ( br= decode (:P1_beds,'null',br,:P1_beds) or size= decode (:P1_size,'null',size,:P1_size) )----------------
    I hope my question is clear
    Regards,
    Fateh

    Assuming you're using the string literal 'null' rather than NULL.
    "it does not seem to work" because of this:
    ( br= decode (:P1_beds,'null',br,:P1_beds) or size= decode (:P1_size,'null',size,:P1_size) )Assuming you pick "office" and :p1_beds is set and :p1_size is 'null', you end up with a statement that is the equivalent of:
    select * from realesate
    where unit_type = 'office'
    and (br = :p1_beds
    or size=size)    <--------------problemand your :p1_beds restriction is then ineffective.
    I'm not a fan of decode to do this logic.
    I prefer a clear statement of exclusive predicates which the optimizer can sometimes deal with more effectively.
    e.g. assuming that it's irrelevant whether you pick office or appartment because the relevant parameter :p1_beds or :p1_size will be set appropriately:
    select * from realestate
    where
          (:p1.property_type is null / = 'null'
    or    (:p1.property_type is not null / != 'null'
    and    unit_type          = :p1_property_type))
    and   (:p1_beds          is null / = 'null'
    or    (:p1_beds          is not null / != 'null'
    and    br                 = :p1_beds))
    and   (:p1_size          is null / = 'null'
    or    (:p1_size          is not null / != 'null'
    and    size               = :p1_size))Note that I've provided alternatives depending on whether you're actually using NULL or a magic string.

  • IR Report based off of page item value

    Hey all,
    I want to create an IRR region and have the report update based off of a a page item.
    The page item will be a drop down of the tables I want to show, so something like:
    Select * from '||v('P1_TABLES')
    This will work with the normal report but not with the IRR. Is the syntax incorrect?
    Help is appreciated!
    Edited by: Ben C on Feb 23, 2012 6:42 AM

    Zooid,
    but always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always always
    use bind variables !!!!
    Regards,
    Richard
    blog: http://blog.warp11.nl
    twitter: @rhjmartens
    If this question is answered, please mark the thread as closed and assign points where earned..

  • How to create a report  based on selected item from Select list?

    Hi,
    I have created a tables_LOV based on:
    select table_name d, table_name r from user_tab_cols
    where column_name like '%_type%'
    Then I created a page item ListOfTables,  Display as select list and pointing to tables_LOV.
    I run the page, and i can select the table i want from the drop down list.
    How to create a report  based on the selected item? (ex: select * from selected_table)
    many thanks in advance
    Salah

    Hi Salah,
    Allright, have a look at this page: http://apex.oracle.com/pls/apex/f?p=vincentdeelen:collection_report
    I think that simulates what you're trying to accomplish. I've set up the simplest method I could think of.
    The report is based on an apex collection. If you are not familiar with that, you should study the documentation: APEX_COLLECTION
    To recreate my example you should:
    1) create an (interactive) report on your collection
    SELECT *
       FROM APEX_collections
    WHERE collection_name = 'MY_COLLECTION'
    2) create a page_item select list for the tables you want to display (in my case this is called "P38_TABLES" )
    3) create a dynamic action that triggers on change of your select list page_item. The dynamic action must be a PL/SQL procedure perfoming the following code:
    declare
      l_query varchar2(4000);
    begin
      l_query := 'select * from '||:P38_TABLES;
      if apex_collection.collection_exists
            ( p_collection_name => 'MY_COLLECTION' )
      then
        apex_collection.delete_collection
          ( p_collection_name => 'MY_COLLECTION' );
      end if;
      apex_collection.create_collection_from_query
        ( p_collection_name => 'MY_COLLECTION'
        , p_query           => l_query
    end;
    Make sure you add your page_item to the "Page Items to Submit" section.
    4) Add an extra true action that does a refresh of the report region.
    Here are two pictures describing the da:
    http://www.vincentdeelen.com/images/otn/OTN_COLLECTION_REPORT_DA1.png
    http://www.vincentdeelen.com/images/otn/OTN_COLLECTION_REPORT_DA2.png
    Good luck and regards,
    Vincent
    http://vincentdeelen.blogspot.com

  • Handle mutually exclusive user parameters

    Handle mutually exclusive user parameters
    Hi Everyone,
    I have a report, needs to handle mutually exclusive user parameters, e.g. District, Region, Location. I need to handle the User Parameter Form in the following scenario, if users put/select a value in District, then other 2 parameters(Region, Location) would show null. The same logic works on the other 2 parameter. Anyway, the report user parameter form shows 3 parameters, however, any choice in one parameter would nullify the other 2. This is not a web report, only paper based, with a default User Parameter Form
    I would be very appreciating if any one can help.
    Regards!
    AChen

    Hi,
    I don't think it is possible to get a dynamic parameter form like that. At most, you can use some Javascript on the parameter form field, eg, if the value is not a number, you show an error msg and so on. But it may not be possible to dynamically change the field values baed on a user action.
    You can do it in a JSP though, that submits request to your paper report.
    Navneet.

  • R12: How to filter Open Item Revaluation Report based on GL Date

    Hi,
    Anybody know how to filter Open Item Revaluation Report based on GL Date from and GL Date to in R12?
    Since we just upgraded from 11.5.10 to 12.1.3 and found we cannot filter those report for specific date. It shown all data included the old data from 8 years ago also.
    We need to run the report only for specific date only. Please share with me if anyone know about this.
    Thanks.

    Pl do not post duplicates - R12: How to filter Open Item Revaluation Report based on GL Date

  • How to Generate a Report Based on User's Parameters from Web Site

    Hi, all,
    I am trying to use Oracle Developer 6.0 Report Builder to generate report based on what user types in from the web site. Since I am a novice, I am wondering if anybody would help me with the following questions:
    1. How can I create a report based on user's parameters?
    Assuming that I have 2 text fields EMPNO and DEPT on the web site, after user types in some value, how can I pass these parameters into my query, can I do something like:
    select ENAME, JOB, EADDRESS from EMP
    where EMPNO =
    some_reference_of_parameters_from_user
    or is there any other way to achieve this functionality?
    2. How can I pass a PDF format report back to user after the report is generated?
    Any help is greately appreciated!!
    Best regards.
    Judy

    Hello,
    In the Report Builder, create two user parameters, and set the parameter name, datatype, width, and default values to what you want. Modify the query and put in a where clause (e.g., where deptno = :p_deptno). When you request the report with PARAMFORM=YES on the URL, it'll generate a default parameter form in HTML and allow the user to enter in the selected parameter values. Also set DESTYPE=CACHE&DESFORMAT=PDF on the URL to get the output back as PDF.
    If you upgrade to Reports 6i, you can customize the default HTML parameter form.
    Regards,
    The Oracle Reports Team --skw                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Report for Shipment cost calculation based on Delviery Line items

    Hi,
    What would be the Standard SAP report where I can find the shipment cost based on Delivery line item. Currently there is a report ME2S that gives the cost based on PO. But I want to find a report based on outbound delivery line item.
    Regards
    Gaurav

    I hope VI11 should help you

  • Report based on a ITEM (which has SQL statement)

    Hi everyone,
    I have a created a form based on a table which has 1 column that stores SQL statement in the database.And i am displaying the SQL statement in TEXT AREA FILED.
    What i want to do is to create a report based on that SQL statement (Which is in the TEXT AREA field on the same page).I tried to create a report region with
    :P25_SQL_STATEMENT.But i am getting an error
    ----->invalid query, no select statement found.
    How can i do a report based on the item which has SQL query in it.
    Thanks
    phani
    .

    Hi Jkallman,
    Thanks for the reply.I have a (FORM WITH REPORT) on a table which has column of SQL_STMNT VARCHAR2(2000 BYTE) which takes the SQL statement entered from the FORM.
    1.I have a report which shows all the records in the above mention table on page 10
    2.If i hit the edit button in the report i go to page 11 which i have the FORM on the above mentioned table.In that form i have a field :P11_SQL_STMNT.
    3.I am trying to create a report on the same page 11 based on the SQL query of that :P11_SQL_STMNT.
    4.I did the follwoing steps
    --> create a region
    ----> report
    ---->sql report
    and entered the following code.
    begin
    return (:P11_SQL_STMNT);
    end;
    but it is giving me the error which i mentioned in the previous post.If u need any more details i can provide
    Thanks in advance
    phani

  • Dynamic report based on Parameters and a Button

    Trying to make a dynmic report based on Parameters entered.Wanted to refresh report when i click on a button say "OK" based on parameters entered.
    (1) created 2 text boxes -- Parameters --One date and other employee No
    (2) on the same page i created a report-region which id dynamic "PL/SQL Function Returning SQL Query "
    In this query i am using the parameters created in step1
    (3) Then i created a Button say "OK" .
    (4) When i enter parameters and then press OK i need to refresh my report in region defined in step2
    This refresh is not happening .
    Not sure what is missing
    I tried using branching it didn't work
    In the dynamic region it shows "No data found"
    Please help

    sachin
    1) make sure there is no Optional Redirect defined on the OK button. That is, make sure the page is really submitted.
    2) in the PL/SQL body generating the query, print out the query using htp.p() so you get to see it and test it.
    3) use the session state link in the developer toolbar in conjunction with the technique in step 2) to debug your query
    Maybe the report region is refreshing, but it just isn't returning any results.
    Sergio

  • Mutually exclusive parameters

    Hi,
    I have 3 parameters in one concurrent request namely Employee, Organization and Project.
    Employee and Organization parameters are mutually exclusive. Project parameter is dependent on either employee or organization depending upon which one is entered. In other words the project parameter valueset is refering to employee and organization using :$FLEX$.employee and :$FLEX$.organization. Now the problem that I am facing here is that the system expects both employee and organization parameters before enabling project parameter on SRS screen. But I want them mutually excluisive and at any point in time only one should be entered in.
    Any pointer towards how to solve this problem is highly appreciated?
    Thanks in advance
    Bhavesh

    Hi,
    I have 3 parameters in one concurrent request namely Employee, Organization and Project.
    Employee and Organization parameters are mutually exclusive. Project parameter is dependent on either employee or organization depending upon which one is entered. In other words the project parameter valueset is refering to employee and organization using :$FLEX$.employee and :$FLEX$.organization. Now the problem that I am facing here is that the system expects both employee and organization parameters before enabling project parameter on SRS screen. But I want them mutually excluisive and at any point in time only one should be entered in.
    Any pointer towards how to solve this problem is highly appreciated?
    Thanks in advance
    Bhavesh

  • Can I pass parameters from a dashboard via a dashboard prompt and presentation variable to publisher report based on a data model with select statements in OBIEE 11g ?

    I have a publisher 11g (v 11.1.1.7)  report with a single parameter. The report is based on a data model not a subject area.  I created a dashboard put a dashboard prompt and link to the report in separate section on the same page.  The dashboard prompt sets a presentation variable named the same as the parameter in the report. 
    The problem was when I created the dashboard prompt, it forced me to select a subject area which I did (though did not want to) and then I created both a column and variable prompts. But clicking on the
    report link completely ignored the value that I thought would be passed in the presentation variable to the report.
    Side note :  My report uses a pdf template for its layout where I have mapped the columns names from my data model to the form fields on the pdf form.  I noticed that if I create a publisher report based on a subject area, then I do not have the choice to choose a PDF as a template type for my layout.  (I only see BI Publisher Template as a choice). 
    I see some documentation online that suggest it could be done in 10g.
    Thanks
    M. Jamal

    Ok,
    I just tried that and it still doesn't pass anything to the prompt.
    I changed the prompt to an edit field and I made the following weblink but when i click the link from an account it doesn't put anything in the prompt and all data for all accounts is shown.
    This is the URL maybe I messed something up...
    https://secure-ausomx###.crmondemand.com/OnDemand/user/Dashboard?OMTHD=ShowDashboard&OMTGT=ReportIFrame&SelDashboardFrm.Dashboard Type=%2fshared%2fCompany_########_Shared_Folder%2f_portal%2f360+Report&Option=rfd&Action=Navigate&P0=1&P1=eq&P2=Account."Account Name"&P3=%%%Name%%%
    thanks

  • Mutually exclusive set of items

    Hi,
    I have 5 check boxes. check box 5 - should not be available if any of the 4 check boxes are checked. and also if check box 5 is checked, none of the other 4 check boxes should be enabled. Could any one give me a suggestion about how to achieve this? Thanks,
    Lakshmi

    Hi Lakshmi,
    If I'm interpreting your question correctly, you don't have a simple case of 5 mutually exclusive choices (1 or 2 or 3 or 4 or 5) - if you do then use a Radio Group.
    I'm thinking, however, that your user can choose multiples from 1-4 but, if they do then 5 is not available e.g. they can choose (1 and 3 and 4 but not 5) or they can choose (5 only).
    One approach would be to define a Validation and check at submit time. Another approach would be to code some Javascript to enable/disable the checkboxes.
    My preference would be for the Validation (and not just because I don't know Javascript).
    Looking at it from a useability perspective, I'd prefer to give the user an explanation on the screen - say a label that indicates which combinations are valid or put checkboxes 1, 2, 3, and 4 in a different region and indicate that the regions are 'mutually exclusive' - and then 'trap' any error they make. Essentially, I'm advocating enabling the user to give the correct response rather than controlling their every mouse click. If it's not obvious what an appropriate choice is, they'll get very confused if a checkbox suddenly become unavailable because they've clicked somewhere else.
    I'd be keen to see what the Javascript coders can come up with, though.
    Cheers,
    Bryan.

  • Refresh classic report based on select list value selected

    hello,
    can anyone please help me out with this issue. I have a parameterized classic report based on a select list and I want to refresh this report whenever the select list value is changed. I am using oracle apex version 3.2. i just want to have a javascript function onchange event for the select list which refreshes my report whenever a value is selected.
    My select list item is p1_datastore
    select distinct datastore d,datastore r from my_table1 order by 1;
    My classic report query is
    select * from my_table2 where datastore = :p1_datastore order by last_updated_dt desc;
    ****************************************************thanks,
    orton

    can anyone please help me out with this issue.
    thanks,
    orton

  • Dynamic report columns in parameterized report

    Hi all,
    Just wanted to share some ideas... I was looking for a way to allow users to seect which columns to display in a parameterized report.
    I came across Denes Kubicek's solution on his APEX demo site (the "Pick Columns" page)... works beautifully.
    The only problem I had was that some of the report columns required joins to other tables. (up to 5 left outer joins). Could not figure out how to do this based on Denes sample solution. I then thought of creating a view, which joined all the required fields for output. I then run my report against the view... this works even better.
    I also used a shuttle instead of a multi-select list, since I have about 25 columns to pick from... I find the shuttle a lot more flexible (re-ordering of columns etc..)
    One thing I still haven't figured out yet though, is how to make the columns sortable? If I check off the sort check box on the report atttributes for the generic "col0"... I get an oracle error...
    If anyone has figured this one out, please let me know..
    Thanks to Denes for the solution...
    Stephane

    Actually, getting the error, albeit intermittently...
    Here is the SQL debug output
    select ECC_No,Opportunity_Name,Opportunity_Status from custom_report_vw where NVL(opportunity_type_id,-1) = decode(:P12_type_id,-1,NVL(opportunity_type_id,-1),:P12_type_id) and NVL(DEPARTMENT_ID,-1) = decode(:P12_dept,-1,NVL(DEPARTMENT_ID,-1),:P12_dept) and 
    NVL(max_5_effort_days,'%null%') = decode(:P12_5_EFFORT_DAYS,'%null%',NVL(max_5_effort_days,'%null%'),:P12_5_EFFORT_DAYS) and
    NVL(IN_FLIGHT,'%null%') = decode(:P12_IN_FLIGHT,'%null%',NVL(IN_FLIGHT,'%null%'),:P12_IN_FLIGHT) and NVL(CLIENT_FUNDED,'%null%') = decode(:P12_CLIENT_FUNDED,'%null%',NVL(CLIENT_FUNDED,'%null%'),:P12_CLIENT_FUNDED)  and 
    NVL(opportunity_category_id,-1) = decode(:P12_category_id,-1,NVL(opportunity_category_id,-1),:P12_category_id) 
    and NVL(priority_id,-1) = decode(:P12_priority,-1,NVL(priority_ID,-1),:P12_priority) and 
    NVL(work_type_id,-1) = decode(:P12_WORK_TYPE,-1,NVL(work_type_id,-1),:P12_WORK_TYPE)
    order by 4,1
    failed to parse SQL query:
    ORA-01785: ORDER BY item must be the number of a SELECT-list expressionFor some reason, in the order by it puts 4,1... but I only have 3 columns in my select list...
    If I choose an additional column, then the query works. I'm also confused as to why it sorts on the 1st column as well? In my report attributes, I do not specify a sort sequence, so I figure it would simply sort on the chosen column index.
    This query used was working fine yesterday with one or two columns...
    Any ideas?

Maybe you are looking for

  • Using a shared library compiled in Linux (.so) on a windows platform

    Hi, Can I interface a shared library compiled in Linux (.so) in LabView on a windows platform? Gabriel Y

  • Image resolution for converted documents and images

    We are converting documents from several different formats to PDF.  We have a requirement that the images must be 300 dpi when converted.  I turned off the down sampling option in PDF settings.  However, the images are all coming out at 72 dpi. So I

  • WRT120N issue: sending hundreds of connection requests per second

    I have a WRT120N and for about 1 year it worked perfectly but then my ISP started cutting off my internet because when the router tried to connect to the internet it sent hundreds of connection requests (or so they sad), even after I upgraded the fir

  • Can't set a custom distance

    I've been using the Nike+ for about 3 months with great success. Today it stopped allowing me to set a custom distance. I can use any of the presets, but it turns any custom distance I set to "3Km" Any way to fix this?

  • Transfer photo and videos

    Why I can't download/transfer any photos and video from my iPhone 4 (iOS 7.1) to my MacBookPro 15" (OSX 10.9.2)? Before the upgrade it was all ok. Please let me know if I have to able something. Thanks, Fibragi.