Multiple Parameter Dynamic Query/Report

I'm very much a newbie to both APEX and SQL. I want to create a page with two regions, one used to hold parameters (LOV Select Lists), and one to reflect a dynamic SQL report including filtering the results using the values of the items in the select lists.
I can do this with one Parameter/LOV select list - but am not clear on how to code for multiple parameters.
Can someone give me an example on how to code the query, to include multiple parameters (P1_Empl, P1_AssetNo, P1_AssetType, etc)? The query with 'null' parameters/filters gives you all records; with any or many parameters acting as filters the query and resulting report would reflect the value of the filters.
In addition, is there a specific type of region that needs to be used for the report region?
Implied is the question - how do you handle the initial page view, so no error messages are seen - I'd like to get all records as a default.
Thanks
Rich

sbkenned,
The referenced sql for that report gives me problems.
[ P3_Department_ID is the LOV of departments ]
[ Null allowed and null return value is -1 ]
<code>
SELECT e.EMPLOYEE_ID,
e.FIRST_NAME,
e.LAST_NAME,
e.HIRE_DATE,
e.SALARY,
e.COMMISSION_PCT,
calc_remuneration(salary, commission_pct) REMUNERATION,
e.DEPARTMENT_ID,
d.DEPARTMENT_NAME
FROM OEHR_EMPLOYEES e,
OEHR_DEPARTMENTS d
WHERE e.DEPARTMENT_ID = d.DEPARTMENT_ID(+) AND
(e.DEPARTMENT_ID = :P3_DEPARTMENT_ID or
(e.DEPARTMENT_ID is null and nvl(:P3_DEPARTMENT_ID,'-1') = '-1'))
</code>
The where clause: I'm guessing it is checking e.deptno = d.deptno
but then what is (+)?
can I use the '(+) and' to add on sections for each select list/parameter?
In the paran part of the where clause, I get the first part and the use of 'or' - but I'm not sure what the last statement is doing.
e.deptno is null AND ?? if there is a null value in P3_Department_ID return -1 otherwise return -1 ??
I'm lost at that point as I clearly don't understand the syntax.
Would you suggest multiple clauses in a where statement in order to add multiple filter values, and how do I handle nulls so those filters are not used/relfected?
I am not using a self submitting LOV select list - I am using a button to refresh the query region manually
I am comfortable with using an interactive report, but that interface is not what I need to present.
As I indicated - I'm weak in the SQL area and need an example on how to code this type of query.
Thanks.
Rich

Similar Messages

  • Dynamic query report problem

    I have followed the tutorial in on dynamic query and created a region where the type is SQL Query (PL/SQL function body returning SQL Query)
    The source is
    declare
    q varchar2(4000);
    teatid NUMBER := :P305_TARGET_ID;
    begin
    wwv_flow.debug('teatid = ' || teatid);
    q:=' select f.id, ';
    q:=q||' f.eat_id ';
    q:=q||' from xmlTransactions f ';
    q:=q||' where f.eat_id = ' || teatid; -- I've also tried putting :P305_TARGET_ID here
    wwv_flow.debug('sql = ' || q);
    return q;
    end;
    I have chosen "Use Generic Column Names...".
    When I run the page, I get NO ROWS FOUND. However, when I cut and paste the SQL statement printed out by the debug statement and run it, it returns rows. Both debug statements print correct values.
    I'm not sure what the problem is here, but basically, I want to do a query where I substitute a value passed into the page from another page.
    In this case the value in P305_TARGET_ID is passed in via a button spawning a popup as in var url = 'f?p=&APP_ID.:305:&APP_SESSION.::::P305_TARGET_ID:' + targetID;
    APEX version is 3.0.1.00.08
    Thank you.
    - JohnW

    Hi, JohnW
    I don't understand why you use a dynamic query for that.
    A "direct" SQL query like this :
    select f.id,f.eat_id from xmlTransactions f where f.eat_id=:P305_TARGET_ID;
    should work.
    Mike

  • Problem on Dynamic Query Report

    Hello,
    I need to perform a report depend on the user who is accesing to my application,
    I am using the following query:
    declare
    q varchar2(4000);
    v_usuario varchar2(10);
    begin
    SET v_usuario = (CASE
    WHEN :P101_USERNAME='janet' THEN v_usuario = 'JA'
    WHEN :P101_USERNAME='cesar' THEN v_usuario = 'CC'
    WHEN :P101_USERNAME='luisjavier' THEN v_usuario = 'LT'
    WHEN :P101_USERNAME='mauricio' THEN v_usuario = 'MO'
    WHEN :P101_USERNAME='enrique' THEN v_usuario = 'EH'
    ELSE ' ')
    q:=' select p.cliente, ';
    q:=q||' p.partner, ';
    q:=q||' p.channel_mgr, ';
    q:=q||' p.fm_sales_rep, ';
    q:=q||' p.status, ';
    q:=q||' p.sc_leader, ';
    q:=q||' p.sector, ';
    q:=q||' p.fecha_inicio, ';
    q:=q||' from adminorv.proyectosongoing p ';
    q:=q||' where p.sc_leader = v_usuario';
    return q;
    end;
    However, I got this error:1 error has occurred
    Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing. ORA-06550: line 1, column 9: PLS-00103: Encountered the symbol "" when expecting one of the following: begin function package pragma procedure subtype type use form current cursor
    Somebody can give a hint?

    You have a bunch of syntax errors there.
    The code should look more like this:
    declare
    q varchar2(4000);
    v_usuario varchar2(10);
    begin
    v_usuario := (CASE
    WHEN :P101_USERNAME='janet' THEN  'JA'
    WHEN :P101_USERNAME='cesar' THEN  'CC'
    WHEN :P101_USERNAME='luisjavier' THEN  'LT'
    WHEN :P101_USERNAME='mauricio' THEN  'MO'
    WHEN :P101_USERNAME='enrique' THEN  'EH'
    ELSE ' ' END);
    q:=' select p.cliente, ';
    q:=q||' p.partner, ';
    q:=q||' p.channel_mgr, ';
    q:=q||' p.fm_sales_rep, ';
    q:=q||' p.status, ';
    q:=q||' p.sc_leader, ';
    q:=q||' p.sector, ';
    q:=q||' p.fecha_inicio ';
    q:=q||' from adminorv.proyectosongoing p ';
    q:=q||' where p.sc_leader = v_usuario';
    return q;
    end;But I don't see why you are using dynamic SQL and a function returning a query here.
    That could be done with just a simple query like this:
    select p.cliente, p.partner, p.channel_mgr, p.fm_sales_rep, p.status, p.sc_leader,
           p.sector, p.fecha_inicio
      from adminorv.proyectosongoing p
    where p.sc_leader = CASE WHEN :P101_USERNAME = 'janet' THEN 'JA'
                              WHEN :P101_USERNAME = 'cesar' THEN 'CC'
                              WHEN :P101_USERNAME = 'luisjavier' THEN 'LT'
                              WHEN :P101_USERNAME = 'mauricio' THEN 'MO'
                              WHEN :P101_USERNAME = 'enrique' THEN 'EH'
                              ELSE ' '
                          END

  • HTMLDB Dynamic Query Reports

    This question is based on Oracle How To: http://www.oracle.com/technology/products/database/htmldb/howtos/dynamic_report-1.6.htm
    I tried creating my own dynamic report as follows below, but it failed in HTMLDB with the error: [Failed to parse SQL query: ORA-00933: SQL command not properly ended]
    I have examined my code quite thoroughly but still cannot understand what the problem is .. i.e. the code seems syntatically correct. Can anyone help please?
    DECLARE
    q VARCHAR2(4000);
    BEGIN
    q:=' SELECT a.customer, ';
    q:=q||' a.country, ';
    q:=q||' b.group_ga, ';
    q:=q||' SUM(nvl(a.total_sla_pass,0))TT_SLA_Pass, ';
    q:=q||' SUM(nvl(a.total_sla_fail,0)) TT_SLA_Fail,';
    q:=q||' SUM(nvl(a.total_sla_unassess,0))TT_SLA_Unassessed,';
    q:=q||' SUM(nvl(a.total_sla_pass,null)) TT_Total';
    q:=q||' FROM ms_portal_load_mv a, ms_portal_load_mv b';
    q:=q||' WHERE a.sh_fix_time >= :p400_Start_Date';
    q:=q||' AND a.sh_fix_time < :p400_End_Date';
    q:=q||' AND a.index_x = 3';
    q:=q||' AND b.index_x = 3';
    q:=q||' AND a.non_sla = 0';
    q:=q||' AND a.group_assignment_id IS NULL';
    q:=q||' AND a.ticket_id = b.parent_ticket_id';
    IF :p400_select_customer != 'All' THEN
    q:= q||'AND a.customer = :p400_select_customer';
    END IF;
    q:=q||' GROUP BY a.customer, a.country, b.group_ga;'
    RETURN q;
    END;

    Thanks for your replies.
    I have tried all suggestions but the code still generates error in HTMLDB:
    # 1 error has occurred
    Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing. ORA-00933: SQL command not properly ended
    Any other ideas?
    Thanks in advance
    Kezie

  • Conditional URL ( CASE )  within a Dynamic Query

    I need extra eyes or help in RE-FORMATTING the following SELECT STMT. My approach was to formulate the following query to get a functioning URL to the page that displayed the corrections made on that record (if it was corrected)...which I did. So now I'm trying to move the CASE portion into a dynamic query report. I'm having difficulties rewriting the CASE into the dynamic query due to placement of single-quotes. Is there an easy way to do this...or do I still need to find the correct placement of quotes? HELP!
    select "ID",
    "EMP_ID",
    "ENTRY_DATE",
    "JOB_TITLE",
    "START_DATE",
    "END_DATE",
    "MODIFIED_DATE",
    "lkup_1"."DESCRIPTION" as "Status",
    CASE
    WHEN rec_status = 'CR' -- corrected record
    THEN '<a href="'
                      || 'f?p=&APP_ID.:90:&SESSION.::&DEBUG.::'
                      || 'P90_RID,P90_TIMESTAMP:'
                      || rid ||',' || TO_CHAR(modified_date,'MM/DD/YYYY')
                      || ">'
    || 'See Update(s)'
    || '</a>'
    || '</a>'
    ELSE NULL
    END LINK,
    "lkup_2"."DESCRIPTION" as "Action",
    "CATEGORY",
    apex_item.checkbox(1,rid) as "Confirm"
    from "JOB_SUMMARIES",
    "LOOKUPS" "lkup_1",
    "LOOKUPS" "lkup_2"
    where "REC_STATUS" <> 'CF'
    and "REC_STATUS" = "lkup_1"."CODE"
    and "ACTION" = "lkup_2"."CODE"(+)
    Here is what I sort of come up with, but I'm getting dizzy looking at it so many times!
    ' CASE '||
    ' WHEN rec_status = ' || '''' || '''CR''' || '''' ||
    ' THEN ' || '''' || '<a href="' || '''' ||
             '            ||' || '''' || 'f?p=&APP_ID.:90:&SESSION.::&DEBUG.::' || '''' ||
             '            ||' || '''' || 'P90_RID,P90_TIMESTAMP:' || '''' ||
             '            ||' || ' id ||' || '''' || ''',''' || '''' || '|| TO_CHAR(modified_date,' || '''' || 'MM/DD/YYYY' || '''' || ')' || '''' ||
             '            ||' || '''' || ">' || '''' ||
    ' ||' || '''' || 'See Update(s)' || '''' ||
    ' ||' || '''' || '</a>' || '''' ||
    ' ||' || '''' || '</a>' || '''' ||
    ' ELSE NULL '||
    ' END LINK, '||
    I'm still getting an error which is:
    1 error has occurred
    * Query cannot be parsed within the Builder. If you believe your query is syntactically correct,
    check the ''generic columns'' checkbox below the region source to proceed without parsing.
    ORA-00905: missing keyword

    I still cannot get the insertion of the CASE to compile...I keep getting MISSING EXPRESSION error.
    1 error has occurred
    * Query cannot be parsed within the Builder. If you believe your query is syntactically correct,
    check the ''generic columns'' checkbox below the region source to proceed without parsing.
    ORA-00936: missing expression
    Here is my dynamic query and I want to place the CASE as indicated. The numerous quotes or the Q syntax is really messing up my attempts to get this page working. I have a dynamic query because I am allowing search parameters. And I thought it would be nice to have a LINK to another page that displayed changed column values if a user CORRECTED one of their records. All changes must be verified and accepted by a REVIEWER.
    declare
    q varchar2(32767); -- query
    w varchar2(4000) ; -- where clause
    we varchar2(1) := 'N'; -- identifies if where clause exists
    begin
    q := 'select "ID", '||
    ' "EMP_ID", '||
    ' "ENTRY_DATE", '||
    ' "JOB_TITLE", '||
    ' "START_DATE", '||
    ' "END_DATE", '||
    ' "lkup_1"."DESCRIPTION" as "Status", '||
    >WANT TO PLACE CASE RIGHT HERE
    ' "lk_up2"."DESCRIPTION" as "Action", '||
    ' "CATEGORY", '||
    ' apex_item.checkbox(1,rid) as "Confirm" '||
    ' from "#OWNER#"."JOB_SUMMARIES", '||
    ' "#OWNER#"."LOOKUPS" "lkup_1", '||
    ' "#OWNER#"."LOOKUPS" "lkup_2" '||
    ' where "REC_STATUS" <> ' || '''' || 'CF' || '''' ||
    ' and "REC_STATUS" = "lkup_1"."CODE" '||
    ' and "ACTION" = "lkup_2"."CODE"(+) ';
    if :P16_EMP_ID != '-1'
    then
    w := ' AND EMP_ID = :P16_EMP_ID ';
    we := 'Y';
    end if;
    if :P16_RECORD_STATUS != '-1'
    then
    w := w || ' AND REC_STATUS = :P16_RECORD_STATUS ';
    we := 'Y';
    end if;
    if :P16_CATEGORY != '-1'
    then
    w := w || ' AND CATEGORY = :P16_CATEGORY ';
    we := 'Y';
    end if;
    if we = 'Y'
    then q := q || w;
    end if;
    return q;
    end;
    Edited by: JSandoval on Aug 10, 2009 3:42 PM

  • Parameter in form for dynamic query in report

    Hello,
    I want to send parameters to report for replacing a dynamic query. I don't know how to make it...
    1.I want my select statement like
    select * from emp
    &p_where_clause
    2.I want to transfer parameters to report to replace the &p_where_clause.
    3.I know I should create a parameter list first, and then use add_parameter built-in to add the parameter, but what I don't know is the correct format of the add_parameter statement.
    4.I know the common format is add_parameter(paramlist,'TEXT_PARAMETER',value) , is it the same format if I want to transfer a select statement to report such as "where deptno in ('25','28','30')" for replacing &p_where_clause in report?
    Thanks in advance
    Joseph

    I appreciate your reply, but I am still a little confused...
    Actually, I want to pass the where clause to report by different condition. Such as when the user choose the deptment 1, then I can transfer the "where dept_no = '1' and empno > 500", or user choose the deptment 2, I can transfer "where dept_no = '2' and company = '0001'". What I want is to pass different where clause to report according to different condition.
    So is it right the statement should be like
    DECLARE
    vWhere1 varchar2 := 'where dept_no = "1" and empno > 500';
    vWhere2 varchar2 := 'where dept_no = "2" and company = "0001"';
    BEGIN
    IF choose = 1 THEN
    ADD_PARAMETER(&P_WHERE_CLAUSE, TEXT_PARAMETER, vWhere1);
    ELSIF choose = 2 THEN
    ADD_PARAMETER(&P_WHERE_CLAUSE, TEXT_PARAMETER, vWhere2);
    END IF;
    END;
    THANKS AGAIN!!
    Joseph

  • Passing single/multiple values to stored proc parameter from crystal report

    I tried below solution posted on this forum to pass either a single value or multi-value to a sql server stored procedure parameter (varchar datatype) from crystal report XI R2.
    In my crystal report , I am displaying all the available parameter values to the user  and the user will select either a single value or multi value.
    This worked when I select single value and when I say show sql query in my subreport  I see the following:
    {CALL "XYZ"."dbo"."storedprocedurename";1('Product  1')}
    But this did not worked when I selected multiple values and when I say show sql query in my subreport  I see the following:
    {CALL "XYZ"."dbo"."storedprocedurename";1('Product 1,Product 2')}
    I think it might work if it is as below:*
    For multiple values:
    {CALL "xyz"."dbo"."storedprocedurename";1('Product 1', 'Product 2')}
    Please advise.
    Solution Posted on this forum is as follows:
    Hi,
    As you must be aware of that a crystal report created of a stored procedure will allow only a single value for inserting a multiple value as a parameter in your report and pass those values to your stored procedure please follow the below work around which will be helpful for you.
    Symptom
    In Crystal Reports, you want to pass a multi-value parameter to a stored procedure. The problem with doing so is that Crystal Reports considers the multi-value parameter to be an array.
    How can you pass a multi-value parameter to a stored procedure?
    Resolution
    Here are the steps to pass a multi-value parameter to a stored procedure:
    1. Create a Crystal report, and add a multi-value parameter.
    2. Since the multi-value parameter is treated as an array, create a formula that uses the JOIN function. Create a formula as below:
    //Formula: @JoinFormula
    Join ({?Multi-value parameter array},";")
    ====================
    NOTE:
    In the formula above, a semi-colon (";") is the delimiter.
    ====================
    3. Within the main report, create a subreport based on the stored procedure, and include the parameter to be populated with the multi-value list.
    4. Link the Join formula in the main report to the stored procedure parameter in the subreport.
    Doing so passes a multi-value parameter to the stored procedure.
    Regards,
    Vinay

    Hi Vinay,
    First you need to make sure the stored procedure accepts multiple values in the fashion 'a','b','c'.
    Then, create this formula in the Main Report:
    numbervar i;
    stringvar s;
    for i:= 1 to ubound({?Parameter}) do
        s := s + "'" + {?Parameter}<i> + "'" + ",";
    left(s,len(s)-1);
    Link this formula to the sub-report's parameter.
    Hope this helps!
    -Abhilash

  • Dynamic Query in Report Builder

    HI
    I have a doubt:
    I need to receive a parameter in my report and I need this parameter in the query, that means, I need to create a dynamic query depending on the value that I receive in one of the parameters that has my report.
    I tried to use the resource of Searching by Reference Cursor tool, it is a blue circle in the Data Model View of Report Builder.
    When I click this tool, I have an initial code, It is:
    function QR_1RefCurDS return <RefCurType> is
    begin
    end;
    In PL/SQL I tried to create to test and to play, this code:
    Note: If you want to try only to test, it is simple and works:
    create or replace package TEST_REFCURTYPE as
    type refcurtype is ref cursor;
    function TEST_REFCURTYPE (P_DATE_TO nvarchar2) return refcurtype;
    end;
    create or replace package body TEST_REFCURTYPE as
    function TEST_REFCURTYPE (P_DATE_TO nvarchar2)
    return refcurtype is
    refcur refcurtype;
    mysql varchar(1000);
    begin
    If P_DATE_TO is not null then
    mysql := 'select '''|| P_DATE_TO ||''' from dual';
    else
    mysql := 'select sysdate from dual';
    end if;
    open refcur for mysql;
    return refcur;
    end;
    end;
    The problem is to pass this example of code to the function QR_1RefCurDS, I do not have a place to make reference to the type:
    type refcurtype is ref cursor;
    I tested the Unit Program in the Report Builder but it did not work, because all the code I try to write and create, for example in the Event BEFORE REPORT, it opens  Funcion( ) …., and I can not make reference to the type refcurtype inside a Function( ).
    Would you help me please?
    Or there is another way to make a dynamic query in the Report Builder?
    Sorry for my English, I am a Brazilian living in Spain.

    Hi,
    you can use lexical parameters in your queries. Instead of a ":" use in the query before the parameter a "&". Then the parameter stands for a part of the query and not for a value (Bind parameter). In the before report trigger you can set this parameters. They can contain parts of SQL like order or where. Make sure that the default value for this lexical parameters are set to get a valid query.
    SELECT ENAME, &p_column as COL2 FROM EMP &p_order
    and in the trigger something like
    IF :p_which_column = 1 THEN
    :p_column := 'SAL'
    ELSE
    Saludos
    Rainer

  • How to pass an array or structure, in addition to a query, or multiple queries to the Report Builder as parameters

    Is there a way to pass an array or structure for example as parameters, in addition to a query, or multiple queries to the Report Builder in CF8? I believe this was recommended by users to be in CF8.

    BrianO,
    Although it's been a while, I thought I'd provide the code to do this for you. It works for me in CF8, and probably will in CF7.
    Here I create a structure called My, and provide that one parameter to my CFReportParam tag.
    <CFSet My = {
    Client = "Client Name",
    ReportDateFrom = DateFormat(ThisStartDate, DateMask),
    ReportDateTo = DateFormat(ThisEndDate, DateMask),
    PageHeaderImage = ImagePath & "\Logos\Page_Header.png",
    WatermarkImage = ImagePath & "\Logos\Watermark.png",
    GetBarSummary = GetBarSummary,
    GetPieSummary = GetPieSummary
    }>
    <CFReport Template="#ReportPath#\SpendSummary.cfr" Format="PDF" Query="GetSummary">
    <CFReportParam Name="My" Value="#My#">
    </CFReport>
    Inside the report itself, reference the given parameter as Param.My.PageHeaderImage for example. It can be referenced that way from any expression inside the report builder. You can even use the queries as the data source for charts (using the Data From a Query -> Query Builder -> Advanced) by entering "Param.My.GetPieSummary" where it says "Variable containing query object".
    HTH
    Swift

  • How to use dynamic parameter when a report is created using Stored Procedures

    Hi all,
    any one have the idea of how to use dynamic parameter in crystal report XI R2
    when report is created using Stored Procedure.
    Regards
    shashi kant chauhan

    Hi
    You can create an SQL command in Database Expert > Expand your datasource > Add command
    Then enter the SQL query that will create the list of values to supply to the user
    eg select field1,field2 from table
    Then edit the parameter of the report.  These will be the SP parameters adn can be seen in field explorer.
    Change the parameter type to Dynamic
    Under the word Value click on Click here to add item
    Scroll down to your Command and select one of the values that you want to appear in the list
    e.g field1
    Then click on the Parameters field - this is essential to create the param
    You can edit other options as required
    That should do it for you.
    I must say that i use CR 2008 connected to Oracle 10g SP, but i reckon this will work for SQL DB and CR XI as well
    Best of luck

  • Print Multiple Parameter Value in Crystal Report 2008

    Hello and Hi
    i want to select multiple warehouse  in a pramater , i select and report working but parameter print only first parameter  value on report.how can print all selected values on report

    Hi
    I am assuming you select warehouses  WH1,WH2,WH3,.......
    You have to create a formula in Crystal
    It should look like this
    Join({?YourParamaterName},",")
    Place the formula on your report.
    The last Part of the formula is the "notation break"  between every parameter returned. In this case a >   ,   <
    Return would be WH1,WH2,WH3,.......
    Join({?YourParamaterName},"#")  would return  WH1#WH2#WH3#.......
    Hope you get the idea
    If this solution helps, please rate me.
    Regards
    Burger

  • How to pass multiple query string values using the same parameter in Query String (URL) Filter Web Part

    Hi,
    I want to pass multiple query string values using the same parameter in Query String (URL) Filter Web Part like mentioned below:
    http://server/pages/Default.aspx?Title=Arup&Title=Ratan
    But it always return those items whose "Title" value is "Arup". It is not returned any items whose "Title" is "Ratan".
    I have followed the
    http://office.microsoft.com/en-us/sharepointserver/HA102509991033.aspx#1
    Please suggest me.
    Thanks | Arup
    THanks! Arup R(MCTS)
    SucCeSS DoEs NOT MatTer.

    Hi DH, sorry for not being clear.
    It works when I create the connection from that web part that you want to be connected with the Query String Filter Web part. So let's say you created a web part page. Then you could connect a parameterized Excel Workbook to an Excel Web Access Web Part
    (or a Performance Point Dashboard etc.) and you insert it into your page and add
    a Query String Filter Web Part . Then you can connect them by editing the Query String Filter Web Part but also by editing the Excel Web Access Web Part. And only when I created from the latter it worked
    with multiple values for one parameter. If you have any more questions let me know. See you, Ingo

  • How to use Dynamic cascading parameter in crystal Report XI ?

    Hi,
    I want to use Dynamic cascading parameter in crystal Report XI which is to be viewed through the infoview without using the Business View.Is it possible?
    I could implemented Dynamic cascading parameter using the CR XI developer without using Business View, but cannot view the report when uploaded it to BOXI, through infoview.
    Please suggest..
    Thanks in advance..
    Rajneesh

    In the crystal reports field explorer>right click on parameter field>create new-->name the parameter field and select the type as dynamic. Now in the value field click the row and add the database field also add another field below that by clicking on the next row so..on. The order should be like this parent field first and then child field next...... Also click on the last column to add parmater for each level.
    Regards,
    Raghavendra

  • Generating Dynamic Query for Ad-Hoc Reports

    Hello,
    What is the best way to create a dynamic query to generate ad-hoc reports? I have a couple of ideas but not sure which would work best and be most flexible.
    I would like our users to be able to check checkboxes for what data they would like returned in their report. The data would be pulled from a number of tables, 10+, depending on what pieces of data they checked.
    Should I write one dynamic query, with a bunch of IF statements in it?
    Should I write many individual queries and then join them together in a temp query?
    Should I create a temp table on our SQL server which contains the data from all of the tables; then query that? (I am worried about data being out-of-date with this option.)
    Which one of these solutions should I go with or is there a better solution that I am not considering?
    Thanks for the help.
    Josh

    Do you mean a Stored Procedure? Would the Stored Procedure then have one query on it with a bunch if IF statements? Maybe a bad example, but something like this?
    Yep.
    I haven't written a proc for a coupla years (I have DB people to do that for me now, bless 'em), but every DB is different, so the approach will vary depending on what DB you have.  It's perhaps time to buy a book or do a google or something.
    Adam

  • Dynamic query to produce crosstab/pivot report

    Hello,
    I've not been able to find any examples similar to my situation but perhaps I'm using the wrong search phrases...
    I'm basically trying to create a cross-tab type report based on a dynamic query (since I do not know how many accounts a person has):
    select '  SELECT x.name, x.type, ' from dual
    union
    select ' max(decode(x.account,'''||m.account||''',x.amount,null)) as "'||substr(s.proj||' '||m.account,1,30)||'",'
      from db1.manager m, db1.person p, pi.charges c, db1.status s
    where m.manager_id = p.id
       and M.ACCOUNT_ID = C.ACCT_ID
       and M.ACCOUNT_STRING = S.project
       and C.JNL = (select max(id) from db1.journ j where j.TYPE ='M')
       and p.username = :username
       and nvl(M.END_DATE, sysdate +1) >= sysdate
    group by m.account, s.proj
    union
    select 'sum(x.amount) grand_total from (select m.account, c.name, c.type, c.amount '
              ||'from db1.manager m, db1.person p, pi.charges c '
              ||'where m.manager_id = p.id '
              ||'and p.username = :P68_PRINC '
              ||'and c.acct_id = m.account_id '
              ||'and c.jnl = (select max(id) '
              ||'from db1.journ j where j.TYPE =''M'')) x '
              ||' group by type, name' from dualThe output from this query for the particular manager I selected is:
    SELECT x.name, x.type,
    max(decode(x.account,'12012',x.amount,null)) as "Internal 12012",
    max(decode(x.account,'17929',x.amount,null)) as "Staged 17929",
    max(decode(x.account,'18054',x.amount,null)) as "Help Software 18054",
    max(decode(x.account,'3428',x.amount,null)) as "Mow 3428",
    max(decode(x.account,'3428',x.amount,null)) as "Mow 3428_1",
    max(decode(x.account,'3508',x.amount,null)) as "Stampede 3508",
    max(decode(x.account,'9102',x.amount,null)) as "Open Collaborative 9102",
    sum(x.amount) grand_total
    from (select m.account, c.name, c.type, c.amount
    from db1.manager m, db1.person p, pi.charges c
    where m.manager_id = p.id
        and p.username = :P68_PRINC
        and c.acct_id = m.account_id
        and c.jnl = (select max(id)
       from db1.journ j where j.TYPE ='M')) x
      group by type, nameThis query generates another query that ultimately produces the report below (please pardon the alignment) that I want to see on a report page.
    NAME     TYPE     Internal 12012     Staged 17929     Help Software 18054     Mow 3428     Mow 3428_1     Stampede 3508     Open Collaborative 9102     GRAND_TOTAL
    #EXAM1221     M                                                                            22                                                                                             22
    #EXAM1222     M                          14.83             14.77                     12.56                          2.22                                                          44.38
    #EXAM1223     M                          6.73                 6.7                             5.7                                  1                                                          20.13
    THOEORY       M                          106.5                                                                                                                                      106.5Should I be using the report type that is based on a 'PL/SQL function body returning SQL query' for this type of report??? If so, how does that get set up?
    Thanks in advance!
    ~Jake

    This solution works in that it generates the proper query. I can copy the query (from debug mode) and paste it in TOAD and it works perfectly. However, in the report page it tells me: "report error:ORA-01403: no data found".
    I found this thread: report error: ORA-01403: no data found when SUM columns
    I did have a couple other regions on the page (previous attempts) that were hidden so I deleted them completely. Still no luck.
    I am also summing up several columns...if that has anything to do with it.
    Does anyone have any suggestions?
    Thanks again!!!
    ~Jake
    Edited by: jhammer on Jul 27, 2010 11:02 AM

Maybe you are looking for

  • How to use Action interface?

    Hello, I haven't been programming in JAVA for very long, just over a month. I understand that intefaces are just method signatures and variables that can be used by a class wich implements them and redefines the methods and/or variables. I know that

  • What is the best technique to resize a clip and overlay it on a difficult shape, like a broken piece or mirror?

    What is the best technique to resize a clip and overlay it on a difficult shape, like a broken piece or mirror?

  • Upgrade Project - 4.7 to ECC 6.0

    Hello Gurus, I am HR Functional consultant and assigned to work on upgrade project (4.7 to ECC 6.0) for the first time. I am new to this environment. Can any one help me with suitable documents to start with. My mail id: [email protected] Points assu

  • Heavily filtered Motion clips crashing FCP

    Hi, I am having some serious issues with a fcp project involving a lot of keying of clips done in Motion. All was running more or less smoothly until I apparently let one too many of my completed motion clips remain unrendered in my fcp timeline. Now

  • SPA9000 for Newbie

    Hi all, I am thinking of buying the SPA400 and SPA900 for my home business. I have never used a PBX before. There are a few questions I would like to ask: 1) We have only one PSTN line. Do we need at least two lines/phone numbers in order to forward