How to - Build a report based on dynamic query

I am using this how to and find out that there is an syntax error on this example, where the and should be where. I got an SQL parsing error when I followed this example until I debugged with the debug while on this page. Has any one using this how to and have the same problem?
if :p600_show != 'ALL' then
q:=q||'and p.category = :p600_show';
end if;
declare
q varchar2(4000);
begin
q:=' select p.category, ';
q:=q||' p.product_name, ';
q:=q||' i.quantity, ';
q:=q||' i.unit_price ';
q:=q||' from demo_product_info p, ';
q:=q||' demo_order_items i ';
q:=q||' where p.product_id = i.product_id ';
if :p600_show != 'ALL' then
q:=q||'and p.category = :p600_show';
end if;
return q;
end;

[regarding bind variables]
Well, from what I saw in
http://www.oracle.com/technology/products/database/htmldb/howtos/dynamic_report-1.6.htm
the dynamic SQL is constructed by doing concatenation of user input and SQL keywords
'select col1,col2 from table where co1='||:P1_COL1
So, this is going to flood the shared pool with unique SQL statements with different values of :P1_COL1 and also subject to SQL injection, isnt it? You obviously disagree and I am happy to be proven wrong, please do so?
To avoid having to deal with SQL parsing errors, you
could put a condition on the region so that it
doesn't render (parse) whenever any elements of
session state are not sufficiently populated to allow
the formation of a valid SQL query that would be
parseable without errors.Thats exactly what I want to do, but didnt know what condition that would be? I didnt see any condition saying "Session state not initialized" or something like that.
Thanks

Similar Messages

  • Interactive report based on dynamic query

    Hello
    I am using Apex 4.1 and have a requirement to create an interactive report based on a dynamic query. This option is available in Classic report but in Interactive this feature is not there. Tried using collections or just a view (thought of changing the view definition during "On load", but structure of the report is already defined based on the definition of the view at design time).
    Is there any way of achieving this?
    Appreciate any help!
    Thanks
    aks

    Try looking at this: http://rakeshjsr.blogspot.com/2010/10/oracle-apex-interactive-report-based-on.html
    Thank you,
    Tony Miller
    Dallas, TX

  • How to do a report based on dynamic apex checkbox item value

    Hi All,
    First of all I would like to thank for taking your time to read this.
    I have created a report region with a dynamic checkbox. Now I would like the user to tick few of these checkboxes and click on another link which will take the values of these checkboxes and run an sql statement. I know how to include a standard page_item's value ('where :=P#_ITEM') but I am totally lost on how to do this with dynamic checkboxes. I have been going through many threads here but all of them talk about deleting and updating the displayed records.
    Could you please help?
    Thanks, Naushad.

    Hi David,
    I have not created any checkboxes in the page, below the sql for generating the checkboxes. Now I would like to run another sql to on some other tables where the values of these checkboxes will be used in the 'where' clause:
    ***SELECT DISTINCT Q1.LOAD_NBR, T.DESTINATION, apex_item.checkbox(1,q1.load_nbr, 'UNCHECKED')"SELECT_LOAD"***
    ***FROM TERMINALS T,***
    ***(SELECT DISTINCT C.LOAD_NBR, SUBSTR(C.PKT_CTRL_NBR,1,3) AS "SHOP"***
    ***FROM CARTON_HDR@WMSR C, PKT_HDR_INTRNL@WMSR P***
    ***WHERE C.PKT_CTRL_NBR = P.PKT_CTRL_NBR AND C.MOD_DATE_TIME > (SYSDATE)-1 AND P.STAT_CODE >39 AND P.PKT_CTRL_NBR NOT LIKE '0%' AND C.STAT_CODE <> 99)Q1***
    ***WHERE Q1.SHOP = T.SHOP_NO***

  • Report based on dynamic query

    I have done the same way as shown in the 'How To document'. But it does not work. It just ignores what is mentioned inside the if-end if construct. I have used the sample application itself and followed exactly what is mentioned in the article.The output is the same for 'ALL' as well as any other category selected.
    I have observed that in the report region, the report type namely 'PL/SQL function body returning SQL Query', the if construct just does not work as expected. The code is accepted without throwing any errors but, the result is only one half works, mostly the if portion, what follows the else is ignored.
    I am not sure whether i am committing a mistake somewhere or there is a bug in the application builder itself.
    Can anybody throw light on this.
    I am using application express 2.1 version

    Thanks for your response.
    The How-to document that referred is available here in the following url:
    http://www.oracle.com/technology/products/database/application_express/howtos/dynamic_report.html
    the PL/SQL code is given below. P22_show is the item name(select list).
    declare
    q varchar2(4000);
    begin
    q:=' select p.category, ';
    q:=q||' p.product_name, ';
    q:=q||' i.quantity, ';
    q:=q||' i.unit_price ';
    q:=q||' from demo_product_info p, ';
    q:=q||' demo_order_items i ';
    q:=q||' where p.product_id = i.product_id ';
    if :p22_show != 'ALL' then
    q:=q||'and p.category = :p22_show';
    end if;
    return q;
    end;

  • How to bulid a Crystal report based on Bex query as source

    Hi,
    I have requirment where the end user wants the query in Crystal.I built a Bex query in Bex query designer.I would like to know how to create crystal report based onthe Bex query.
    Thanks,

    Hi
    The Crystal Reports are integrated with BW such that the query built in BW can be used to bulit Crystal Reports on them.
    After launching the Crystal Reports, you will have and option : "Open reprt from BW" whcih will help you in opening the BW Queries and create Crystal Reports.
    Also in the Menu there is an optin SAP-->Create New Report from a Query
    Regards, Hyma
    Edited by: Hymavathi Yanamadala on Aug 13, 2009 5:52 AM

  • 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

  • How to create a report based on a DataSet programatically

    I'm working on a CR 2008 Add-in.
    Usage of this add-in is: Let the user choose from a list of predefined datasets, and create a totally empty report with this dataset attached to is. So the user can create a report based on this dataset.
    I have a dataset in memory, and want to create a new report in cr2008.
    The new report is a blank report (with no connection information).
    If I set the ReportDocument.SetDataSource(Dataset dataSet) property, I get the error:
    The report has no tables.
    So I must programmatically define the table definition in my blank report.
    I found the following article: https://boc.sdn.sap.com/node/869, and came up with something like this:
    internal class NewReportWorker : Worker
          public NewReportWorker(string reportFileName)
             : base(reportFileName)
    public override void Process()
             DatabaseController databaseController = ClientDoc.DatabaseController;
             Table table = new Table();
             string tabelName = "Table140";
             table.Name = tabelName;
             table.Alias = tabelName;
             table.QualifiedName = tabelName;
             table.Description = tabelName;
             var fields = new Fields();
             var dbField = new DBField();
             var fieldName = "ID";
             dbField.Description = fieldName;
             dbField.HeadingText = fieldName;
             dbField.Name = fieldName;
             dbField.Type = CrFieldValueTypeEnum.crFieldValueTypeInt64sField;
             fields.Add(dbField);
             dbField = new DBField();
             fieldName = "IDLEGITIMATIEBEWIJS";
             dbField.Description = fieldName;
             dbField.HeadingText = fieldName;
             dbField.Name = fieldName;
             dbField.Type = CrFieldValueTypeEnum.crFieldValueTypeInt64sField;
             fields.Add(dbField);
             // More code for more tables to add.
             table.DataFields = fields;
             //CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo info =
             //   new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo();
             //info.Attributes.Add("Databse DLL", "xxx.dll");
             //table.ConnectionInfo = info;
             // Here an error occurs.
             databaseController.AddTable(table, null);
             ReportDoc.SetDataSource( [MyFilledDataSet] );
             //object path = @"d:\logfiles\";
             //ClientDoc.SaveAs("test.rpt", ref path, 0);
    The object ClientDoc referes to a ISCDReportClientDocument in a base class:
       internal abstract class Worker
          private ReportDocument _ReportDoc;
          private ISCDReportClientDocument _ClientDoc;
          private string _ReportFileName;
          public Worker(string reportFileName)
             _ReportFileName = reportFileName;
             _ReportDoc = new ReportDocument();
             // Load the report from file path passed by the designer.
             _ReportDoc.Load(reportFileName);
             // Create a RAS Document through In-Proc RAS through the RPTDoc.
             _ClientDoc = _ReportDoc.ReportClientDocument;
          public string ReportFileName
             get
                return _ReportFileName;
          public ReportDocument ReportDoc
             get
                return _ReportDoc;
          public ISCDReportClientDocument ClientDoc
             get
                return _ClientDoc;
    But I get an "Unspecified error" on the line databaseController.AddTable(table, null);
    What am i doing wrong? Or is there another way to create a new report based on a DataSet in C# code?

    Hi,
    Have a look at the snippet code below written for version 9 that you might accommodate to CR 2008, it demonstrates how to create a report based on a DataSet programmatically.
    //=========================================================================
    +           * the following two string values can be modified to reflect your system+
    +          ************************************************************************************************/+
    +          string mdb_path = "C:
    program files
    crystal decisions
    crystal reports 9
    samples
    en
    databases
    xtreme.mdb";    // path to xtreme.mdb file+
    +          string xsd_path = "C:
    Crystal
    rasnet
    ras9_csharp_win_datasetreport
    customer.xsd";  // path to customer schema file+
    +          // Dataset+
    +          OleDbConnection m_connection;                         // ado.net connection+
    +          OleDbDataAdapter m_adapter;                              // ado.net adapter+
    +          System.Data.DataSet m_dataset;                         // ado.net dataset+
    +          // CR variables+
    +          ReportClientDocument m_crReportDocument;          // report client document+
    +          Field m_crFieldCustomer;+
    +          Field m_crFieldCountry;+
    +          void CreateData()+
    +          {+
    +               // Create OLEDB connection+
    +               m_connection = new OleDbConnection();+
    +               m_connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mdb_path;+
    +               // Create Data Adapter+
    +               m_adapter = new OleDbDataAdapter("select * from Customer where Country='Canada'", m_connection);+
    +               // create dataset and fill+
    +               m_dataset = new System.Data.DataSet();+
    +               m_adapter.Fill(m_dataset, "Customer");+
    +               // create a schema file+
    +               m_dataset.WriteXmlSchema(xsd_path);+
    +          }+
    +          // Adds a DataSource using dataset. Since this does not require intermediate schema file, this method+
    +          // will work in a distributed environment where you have IIS box on server A and RAS Server on server B.+
    +          void AddDataSourceUsingDataSet(+
    +               ReportClientDocument rcDoc,          // report client document+
    +               System.Data.DataSet data)          // dataset+
    +          {+
    +               // add a datasource+
    +               DataSetConverter.AddDataSource(rcDoc, data);+
    +          }+
    +          // Adds a DataSource using a physical schema file. This method require you to have schema file in RAS Server+
    +          // box (NOT ON SDK BOX). In distributed environment where you have IIS on server A and RAS on server B,+
    +          // and you execute CreateData above, schema file is created in IIS box, and this method will fail, because+
    +          // RAS server cannot see that schema file on its local machine. In such environment, you must use method+
    +          // above.+
    +          void AddDataSourceUsingSchemaFile(+
    +               ReportClientDocument rcDoc,          // report client document+
    +               string schema_file_name,          // xml schema file location+
    +               string table_name,                    // table to be added+
    +               System.Data.DataSet data)          // dataset+
    +          {+
    +               PropertyBag crLogonInfo;               // logon info+
    +               PropertyBag crAttributes;               // logon attributes+
    +               ConnectionInfo crConnectionInfo;     // connection info+
    +               CrystalDecisions.ReportAppServer.DataDefModel.Table crTable;+
    +               // database table+
    +               // create logon property+
    +               crLogonInfo = new PropertyBag();+
    +               crLogonInfo["XML File Path"] = schema_file_name;+
    +               // create logon attributes+
    +               crAttributes = new PropertyBag();+
    +               crAttributes["Database DLL"] = "crdb_adoplus.dll";+
    +               crAttributes["QE_DatabaseType"] = "ADO.NET (XML)";+
    +               crAttributes["QE_ServerDescription"] = "NewDataSet";+
    +               crAttributes["QE_SQLDB"] = true;+
    +               crAttributes["QE_LogonProperties"] = crLogonInfo;+
    +               // create connection info+
    +               crConnectionInfo = new ConnectionInfo();+
    +               crConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE;+
    +               crConnectionInfo.Attributes = crAttributes;+
    +               // create a table+
    +               crTable = new CrystalDecisions.ReportAppServer.DataDefModel.Table();+
    +               crTable.ConnectionInfo = crConnectionInfo;+
    +               crTable.Name = table_name;+
    +               crTable.Alias = table_name;+
    +               // add a table+
    +               rcDoc.DatabaseController.AddTable(crTable, null);+
    +               // pass dataset+
    +               rcDoc.DatabaseController.SetDataSource(DataSetConverter.Convert(data), table_name, table_name);+
    +          }+
    +          void CreateReport()+
    +          {+
    +               int iField;+
    +               // create ado.net dataset+
    +               CreateData();+
    +               // create report client document+
    +               m_crReportDocument = new ReportClientDocument();+
    +               m_crReportDocument.ReportAppServer = "127.0.0.1";+
    +               // new report document+
    +               m_crReportDocument.New();+
    +               // add a datasource using a schema file+
    +               // note that if you have distributed environment, you should use AddDataSourceUsingDataSet method instead.+
    +               // for more information, refer to comments on these methods.+
    +               AddDataSourceUsingSchemaFile(m_crReportDocument, xsd_path, "Customer", m_dataset);+
    +                              +
    +               // get Customer Name and Country fields+
    +               iField = m_crReportDocument.Database.Tables[0].DataFields.Find("Customer Name", CrFieldDisplayNameTypeEnum.crFieldDisplayNameName, CeLocale.ceLocaleUserDefault);+
    +               m_crFieldCustomer = (Field)m_crReportDocument.Database.Tables[0].DataFields[iField];+
    +               iField = m_crReportDocument.Database.Tables[0].DataFields.Find("Country", CrFieldDisplayNameTypeEnum.crFieldDisplayNameName, CeLocale.ceLocaleUserDefault);+
    +               m_crFieldCountry = (Field)m_crReportDocument.Database.Tables[0].DataFields[iField];+
    +               // add Customer Name and Country fields+
    +               m_crReportDocument.DataDefController.ResultFieldController.Add(-1, m_crFieldCustomer);+
    +               m_crReportDocument.DataDefController.ResultFieldController.Add(-1, m_crFieldCountry);+
    +               // view report+
    +               crystalReportViewer1.ReportSource = m_crReportDocument;+
    +          }+
    +          public Form1()+
    +          {+
    +               //+
    +               // Required for Windows Form Designer support+
    +               //+
    +               InitializeComponent();+
    +               // Create Report+
    +               CreateReport();+
    +               //+
    +               // TODO: Add any constructor code after InitializeComponent call+
    +               //+
    +          }+//=========================================================================

  • How to generate a report based on account description

    Hi Experts,
    How to generate the report based on account description, that means
    i want to generate a report on G/L account and which account numbers are having 'CASH' description.
    for Ex: G/L a/c no: 25010026-Cash and Bank balance(des)
    G/L a/c no: 101000-Cash-freight
    like this.
    please help to do this,
    good answer will be appreciated with points,
    Thanks in advance
    Venkat

    Hi shana,
    my requirement is
    I have G/L account numbers, that account numbers having some descriptions, in these some descriptions are belongs to cash transactions, i want to generate the report on these cash transactions, and the report is " G/L account, debit cash, credit cash, balance".
    is it possible or not,
    thanks in advance,
    Venkat

  • How to build a report in web Intelligence using Store procedure under Microsoft SQL Server 2000

    Post Author: ltkin
    CA Forum: WebIntelligence Reporting
    Hi,
    How to build a report in web Intelligence using Store procedure under Microsoft SQL Server 2000 ?
    Regards,

    Hi ltkin,
    Unfortunately, it is not possible in Xir2 to create Webi reports from stored procedures.
    Webi reports can only be created from Universe. So in Business Objects XIR3 we can create a special universe that enables Web Intelligence user's to access stored procedures residing in the database. This is the only way that Web Intelligence user's can access stored procedures.
    Please let me know if the above information helps.
    Regards,
    Pavan

  • How to biod Crystal Reports based on ABAP Tables/Views

    Hi,
      Can any one post me some document stuff on building Crystal reports based on ABAP Tables/Views please!
    Thanks,
    Madhu.

    Hi,
    Check out the links below for Crystal Reports :
    Re: Crystal report in SAP BW
    http://support.businessobjects.com/documentation/product_guides/
    http://help.sap.com/saphelp_nw04/helpdata/en/86/06a8d3be17fc47aa8d850e50cf5f24/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/46/dfd33b1ed4b47de10000000a114084/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/34/c0523e83464644e10000000a114084/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/0d/5f72b7c0e943d99f4f5cef2bfacfe1/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/06/00a63b60f26e3be10000000a114084/frameset.htm
    Hope this helps.
    Cheers,
    Kedar

  • Bold a single row in a Report based on SQL Query

    Should be easy? So, how do I bold a single row in a report based on SQL query without creating a new template or writing Java for the page? What is the Tabular Form Element "Element Attributes" field for? Or what am I supposed to put in there to make it do anything?

    One way to do this is to add a hidden column to your report which contains the formatting value, for example:
    select empno
    , ename
    , sal
    , decode(empno,1,'font-weight:bold','font-weight:normal') style
    from emp
    Hide the STYLE column.
    Then you can use this column for each column in Column Formatting > HTML expression in this way:
    <span style="#STYLE#">#SAL#</span>
    Unfortunately you have to do this for each colum you want to appear bold.
    good luck,
    Dirk Dral

  • How to create a report from multiple dynamic XMLs

    Hi,
    I'm trying to build a consolidated report that gets data from multiple XML files and each XML file is different. Although the presentation of the data will be similar, the contents of the XMLs will vary and the number of XMLs to merge will also vary.
    What I would like to understand is the following:
    * Is it possible to generate a report template based on dynamic columns where the column names, their format and number is different for each business object?
    * Is it required to generate an XML with the entire data or can the template read information from different XML files? and if so how it can be done. Please notice that the formatting of each XML may be different.
    * Is it possible to use the services to generate the reports directly? Something around these lines was mentioned in one of the sessions but it was also mentioned that it's still WIP.
    I've been using the standalone version and although I can get the desired result, I couldn't merge data from multiple XMLs.
    Is the new BIP version available, or an enterprise version that I can use?
    Thanks in advance,

    Hi Rich,
    Even i had a similar kind of problem. I wanted to fetch data from BI through the XMLA Connector which are created in Query Designer and then i wanted to fetch these fields and rearrange them and put it in a report format by colouring certain fields. Can the same can be done in WebDynpro.

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to create a report based on the selection of a node of a tree

    Hello,
    I am new to Oracle Apex and I was trying to build a tree and also an interactive report based on the empno column of the emp table.
    I have created a tree based on emp table. Now I want to display records of the employee selected in the tree.
    Here is the tree query:
    select case when connect_by_isleaf = 1 then 0
    when level = 1 then 1
    else -1
    end as status,
    level,
    "ENAME" as title,
    null as icon,
    "EMPNO" as value,
    null as tooltip,
    null as link
    from "#OWNER#"."EMP"
    start with "MGR" is null
    connect by prior "EMPNO" = "MGR"
    order siblings by "ENAME"
    Can anyone tell me step by step how to go from here?
    I tried to follow the thread Re: tree question but could not understand much from it.

    The approach for reloading the page and displaying the report is quite simple.
    <li>You start by creating a new page item which would be used to store the selected node ID , eg. P100_SELECTED_NODE (you can make it atext item and change it hidden once everything works as expected)
    <li>Modify the tree query and change the link column in the tree definition SQL query to a link to the same
    for example if your page is 100 , you would make the tree node link to the same page but set the P100SELECTED_NODE with selected node's id_
    This done here
    {message:id=4410987}
    In this case it would be
    'f?p=&APP_ID.:100:'||:APP_SESSION||'::::P100_SELECTED_NODE:'||EMPNO as link Now when you click on a tree node link , it would come back to the same page, but set the P100_SELECTED_NODE with the empno of the clicked node.
    <li> All that is left to do, is changing your Report so that it refers to the new item inorder to filter the records for this employee i.e empno
    SELECT ...
    WHERE empno= :P100_SELECTED_NODE

  • Generating report based on dynamically generated sql query

    I have to rewrite asp reports to oracle reports.
    The original application has forms in asp where reports are generated dynamically based on the options selected.
    There are many options to select.
    Some add filter criteria to where clause.
    I have no problem with this. As i can generate report using parameter form.
    whereas i don't know how to generate reports whose columns change based on the user selection.
    The front end screens are going to be in java and jsp pages. The only way i can think of is generating reports on all possible options the user may select. But, as there are more than 15 options, i think this is not the right approach.
    How can i achieve this.
    Thank you very much.
    navya.

    One method that comes to mind would be to use an after parameter form, and use lexical parameters to create dynamic statements.
    For example in your after pform:
    If :P_NAME = 'JOHN' then
    :P_SELECT = 'SELECT COL1, COL2 ';
    :P_FROM = 'FROM JOHN ';
    :P_WHERE = 'WHERE COL3 = 'JOHN';
    END IF;
    Then in your query, you could say:
    &P_SELECT
    &P_FROM
    &P_WHERE
    Something like that - If only parts of you where statement will change, you can just write that one part -
    like
    IF :P_STATE is not null then
    :P_STATE = ' and table.state = :P_STATE_IN ';
    else :P_STATE = ' and 1=1 ';
    end if;
    and in your query...
    where....
    &:P_STATE
    So IF a person enters a state, then limit the search to that state, or else do a 1=1.
    Hope this gives you a start

Maybe you are looking for