Interactive report dynamic where clause

Hello!

Is it possible that a report interactive sql source can have a where clause clause that is built dynamically?

Marc

Marc:

You could empty the record-ID set in a collection of the APEX.
Change the IR query to add a join for this collection. Something like

select c1, c2,c3...
from  main_tab a, apex_collections b
where b.name='RECORD_IDS'
and a.pk_col=b.to_number(c001)

More about APEX collections can be found at
http://download.Oracle.com/docs/CD/E14373_01/AppDev.32/e11838/advnc.htm#insertedID4

CITY

Tags: Database

Similar Questions

  • Need help with dynamic where clause.

    Hello world.  I'm kind of a novice with PL/SQL, so please be patient with me.  I am building a web application using Weblogic Oracle 11 g and Oracle database.

    To make a long story short, I need to generate the complex dynamic WHERE clause.  I don't know what will be the name of the column or the operator of comparison or the value will be until the moment of execution.

    I'm not 100% certain, but I think I need to use dynamic SQL statements.  Unless there is a better way to do it.

    I'm sure that using dynamic SQL opens me up to SQL injection attacks if I use simple string concatenation.  I would like to use bind variable if possible.

    In any case, it seems like trying to build a dynamic where clause does not seem to work as I want it would be...

    bv1 := 'colA = 5 and colB >= 9';
    
    query_str := 'SELECT * FROM view WHERE :bv1';
    
    OPEN CUR FOR query_str USING bv1;
    

    The code above pours out when I try to run it.

    Is there a way to build dynamic where the provisions without the use of concatenation of simple string that leaves me open to attacks by SQL injection?

    Thank you

    Hello.  I have read briefly upward on things, you suggested, but it seems a bit abstract for me since I was a novice.

    Can you give us an explanation or an example of how to use it to accomplish what I need to do?

    Do ypu really plan create a query with a WHERE clause that contains a predicate for all possible columns?

    Variable bind offer performance when the same query is executed several times with different values for bind variables.

    Select * from emp where empno =: v_empno

    After the first run Oracle will always be this query in the library cache. The next running can use the version of the cache even if the bind value is different.

    Select * from emp where empno =: v_empno;

    Select * from emp where ename =: v_ename;

    Select * from emp where sal =: v_sal;

    Each one is a DIFFERENT query. Yes - each of them uses a variable binding, but queries are different.

    So, if your username select EMPNO, an '=', and a value from the first query can be executed. But the next time that the user can select the ENAME column so that 'stored' first request may not be used given that the query does not match.

    The third time your user selects SAL so none of the first two queries can be used in the library cache. The use of bind variables gives performance during the SAME QUERY is used multiple times with DIFFERENT values for the variable binding. Oracle is not to analyze the hard query everything simply because the VALUE is different.

    So bind variables do not help you if most of the queries were completely DIFFERENT sets of predicates. And SYS_CONTEXT will not help either since that simply provides a way to define binds the values of the variables.

    Just for the simple example above, there are at least SIX possible combinations of columns that could choose your user name: empno, ename, sal, empno ename, empno & sal, ename & sal

  • dynamic where clause ofa

    Dear all,

    I have a problem in the dynamic where clause in the OPS.

    I have a VO query as below:

    SELECT desc, ccuid, containid, XXXTMP conainline

    I'll put whereclause as below:

    VO.setwhereclause ("containid '101' =" + "order by containline desc")

    so the question is request forms as below:

    SELECT desc, ccuid, containid, XXXTMP conainline

    (where containid = '101' containline desc order) -query gives question, adding the command from the inside of the caliper

    Ideally, order by clause should come outside of the Stirrup.

    so, how do I do order by clause order side where clasue or how do I remove the stand before the where clause. So I need the query as below:

    SELECT desc, ccuid, containid, XXXTMP conainline

    (where containid = '101' containline desc order)

    SELECT desc, ccuid, containid, conainline from XXXTMP where containid = '101' containline desc order

    or

    SELECT desc, ccuid, containid, XXXTMP conainline

    (where containid = '101') order by containline desc

    Thank you

    Hello

    Solution 1-

    You can use "setOrderByClause (containline desc);" so that it will get out of Where clause.

    Solution 2-

    Instead of dynamically add Whereclause, you can bind the variable as below-

    Query in VO-

    SELECT desc, ccuid, containid, conainline from XXXTMP where containid =: 1 containline desc order


    In VOImpl-

    public void initQuery (String variable)

    {

    clearCache();

    setMaxFetchSize(-1);

    setWhereClause (null);

    setWhereClauseParams (null);

    setWhereClauseParam (0, variable);

    executeQuery();

    }

    Vall of this VOImpl method, and pass the variable value. It will work according to your requirement.

    Thank you

    Kone

  • Very Urgent: Setting dynamic where clause for Popup list VO

    Hello world


    It is a very urgent requirement please help as soon as possible.


    I have a custom page in iSupplier. I created two supplier site, number of PO fields.

    Site of beg - choice of Message and PO number - Message LOV of entry


    I have a named VO under xxisupplier.oracle.apps.pos.home.poplist.server for site begging and xxisupplier.oracle.apps.pos.home.lov.server for PO number.

    I have joined these two VO AM homepage.




    Now the question is

    1. I want to restrict these VO vendor_id-based so I'll put dynamically where clause for these two VO of in my CO


    VO SITE PROVIDER QUERY


    SELECT POVs.vendor_site_code site, pov.vendor_id
    OF po_vendors pov, povs po_vendor_sites_all
    WHERE pov.vendor_id = povs.vendor_id
    AND TRUNC (povs.inactive_date) IS NULL


    PO NUMBER LOV QUERY VO


    SELECT DISTINCT ai.invoice_num, ai.vendor_id, ai.invoice_date, poh.segment1
    AI ap_invoices_all,.
    help ap_invoice_distributions_all,
    po_headers_all poh,
    po_distributions_all pda,
    Al ap_lookup_codes
    WHERE aid.po_distribution_id = pda.po_distribution_id
    AND ai.invoice_id = aid.invoice_id
    AND poh.po_header_id = pda.po_header_id
    AND ai.invoice_type_lookup_code = al.lookup_code
    AND al.lookup_type = 'INVOICE TYPE'


    I am creating where cluase as below in CO



    If (vendor_id1! = null)
    {
    System.out.println ("vendor_id:" + vendor_id1);
    OAViewObjectImpl vo = (OAViewObjectImpl) am.findViewObject ("PO_LOV_VO");
    if(vo!=null)
    {
    vo.clearCache ();
    VO. Reset();
    System.out.println ("inside IN. VO:" + vendor_id1);
    vo.setWhereClause (null);
    vo.setWhereClause ("vendor_id =: 1");
    vo.setWhereClauseParams (null);
    vo.setWhereClauseParam(0,vendor_id1);
    vo.setOrderByClause ("invoice_date DESC");
    String INVQRY = vo.getQuery ();
    System.out.println ("INVQRY:" + INVQRY);
    vo.executeQuery ();
    VO. First();
    System.out.println ("after the query appear" + vo.getRowCount ());
    }

    OAViewObjectImpl sitevo1 = (OAViewObjectImpl) am.findViewObject ("SUPPLIER_SITE_VO1");
    if(sitevo1!=null)
    {
    sitevo1.clearcache ();
    sitevo1. Reset();
    System.out.println ("Interior site:" + vendor_id1);
    sitevo1.setWhereClause (null);
    sitevo1.setWhereClause ("vendor_id =: 1");
    sitevo1.setWhereClauseParams (null);
    sitevo1.setWhereClauseParam(0,vendor_id1);
    String SITEQRY = sitevo1.getQuery ();
    System.out.println ("SITEQRY:" + SITEQRY);
    sitevo1. ExecuteQuery();
    sitevo1. First();
    System.out.println ("after the query appear" + sitevo1.getRowCount ());
    }



    Here he works for the purchase order number but the where cluase does not work for Supplier Site. Please help as soon as possible.


    2 and also if supplier site to return multiple values then this field should show as messagechoice. If it returns a single value, then it should be the style text message
    How can I achieve this.



    Thank you
    CSK

    Try

    vo.setWhereClause ("IN vendor_id (" + vendor_id_qry + ")" ");

    vendor_id_qry is the query that retrieves the list of provider IDS. You don't need to put the vendor column id as whereClauseParam unless you want to have IN the clause in your query of VO and pass the list as 1,2,3 values to the parameter.

    Thank you
    Shree

  • Dynamic where clause of user defined reports

    Hello everyone,

    Is there a way to make / calculate a where clause clause in a user defined report according to the value of some bind variables?
    I am trying to remove where the terms of my application if the binding variable is not defined.
    previously, I did something as
    AND tab.column = nvl (: colum_bin, tab.column)

    but there are problems in implementation plans.

    Stone

    Sure that you can not, but how about you to rewrite the NVL in

    OR: colum_bin IS NULL

    Hope that helps,
    K.

  • Construction of a dynamic Where clause:

    Hi experts,

    In my environment real time in the java code for a statement select query they they add dynamically to the place where clause and retrieve the data using hybernet. I want to do it in PL/SQ


    (1) is it possible?

    (2) how can I do this

    (3) can provide you with the example of document or for example for this one. Please help me

    >
    In my environment real time in the java code for a statement select query they they add dynamically to the place where clause and retrieve the data using hybernet. I want to do it in PL/SQ

    (1) is it possible?
    >
    Non - Oracle can not recover the data using hybernet.
    >
    (2) how can I do this
    >
    You can't - see response to #1 above
    >
    (3) can provide you with the example of document or for example for this one. Please help me
    >
    Not until give you an example of a document or an example of what you speak again.

  • Dynamic where clause in SP

    Hi experts,

    I use Oracle Database 10 g Enterprise Edition Release 10.2.0.3.0 - 64 bit

    I have to write a MS which has dynamic where clouse this where to accept the form of the value of the parameter.

    This is my SP and Eroor.
    CREATE OR REPLACE
    PACKAGE PKG_EW_PROJection_QUERY AS
    
      PROCEDURE PR_PROJECTION_QUERY(PD_AS_OF_DATE IN DATE,
                                   PV_MEMBER_CODE IN VARCHAR2,
                                   PV_TYPE_LIST   IN VARCHAR2,    -- here i have different input paramater and depending on this my where where clouse will be change 
                                                                                   -- so my input string look like('abd,cfd,fgh') if it abd then my where condition different and if cfd
                                                                                    -- then  where condition different.
                                   CUR_PROJECTION_OUT  OUT      SYS_REFCURSOR);
                                   
                                   
    END PKG_EW_PROJection_QUERY;
    
    /
    
    CREATE OR REPLACE
    PACKAGE BODY PKG_EW_PROJection_QUERY AS
    
      PROCEDURE PR_PROJECTION_QUERY(PD_AS_OF_DATE IN DATE,
                                   PV_MEMBER_CODE IN VARCHAR2,
                                   PV_TYPE_LIST   IN VARCHAR2,
                                   CUR_PROJECTION_OUT  OUT      SYS_REFCURSOR)
                                   IS
               sql_stmt varchar2(1000);
    BEGIN 
             IF PV_TYPE_LIST LIKE '%GRA-PRINCIPAL%' THEN
    
          SQL_STMT := 'SELECT P.FIC_MIS_DATE, P.V_MEMBER_CODE, P.V_TXN_DESC, P.N_AMOUNT_LCY FROM FCT_PROJECTIONS P, DIM_TXN_DESC D';
          SQL_STMT := SQL_STMT ||' WHERE P.N_RESOURCE_GROUP_NBR=D.N_RESOURCE_NBR AND P.V_TXN_CODE=D.V_TXN_CODE';
          SQL_STMT := SQL_STMT ||' AND P.FIC_MIS_DATE ='||PD_AS_OF_DATE;
          SQL_STMT := SQL_STMT ||' AND V_MEMBER_CODE='||PV_MEMBER_CODE;
          SQL_STMT := SQL_STMT ||' AND D.V_BRANCH_CODE=' ||'GRA';
          SQL_STMT := SQL_STMT ||' AND D.V_TXN_CODE='||'REP'; 
          end if; 
        
           OPEN CUR_PROJECTION_OUT FOR  SQL_STMT;
                                          
    END PR_PROJECTION_QUERY;
                                   
    END PKG_EW_PROJection_QUERY;
    
    and i got below error
    
    Error starting at line 2 in command:
    EXEC PKG_EW_PROJection_QUERY.PR_PROJECTION_QUERY('31-JUL-2011','PAK','GRA-PRINCIPAL',:CUR_POS_OUT)
    Error report:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01003: no statement parsed
    00604. 00000 -  "error occurred at recursive SQL level %s"
    *Cause:    An error occurred while processing a recursive SQL statement
               (a statement applying to internal dictionary tables).
    *Action:   If the situation described in the next error on the stack
               can be corrected, do so; otherwise contact Oracle Support.
    CUR_POS_OUT
    ------
    can you please let me know where I hurt m.

    If you need more information please let me know.

    Thank you
    Ritesh.

    You do not have anything in your example that requires dynamic sql.

    Consider this:

    declare
       cursor my_cur (val1 varchar2, val2 number) is
            select column1, column 2
            from table1
            where column1 = val1
                and column2 = val2;
    begin
         if your_condition then
             --process the cursor declared above
             for cur_rec in my_cur ('ABC', 12)
             loop
                  do something
             end loop;
          end if;
    end;
    

    In your example, you're just concatenate strings together, which could be managed with variables.

  • Hide filter interactive report dynamically after the page load

    Hello

    I try to hide the section of interactive report filters (hide/show the area with +/-sign on the top of the report) the loading of the page

    I have the reference to the thread after http://apex-at-work.blogspot.com/2011/02/hide-interactive-report-filter.html posted by Tobias Arnhold...

    According to the expert, all I have to do is post the following code the code JS "page loading" within a dynamic action...


    / * Hide filter IRR after page load * /.
    If ($('#apexir_CONTROLS_IMAGE').attr ("src") == ' / i/minus.gif ') {}
    gReport.toggle_controls ($x ('apexir_CONTROL_PANEL_CONTROL'));
    }

    I did, but apparently it does not work for me...

    I posted a sample on APEX. Oracle.com for review and comment

    Thank you

    Edited by: qwe12654 may 3, 2011 19:15

    Hello

    01. in the report Footer region put this

    
    

    * This will hide your filters, highlight conditions

    02. then Goto 'Report attributes' => 'Search Bar' => for 'Include search bar' select 'no '.
    * This will hide the full search bar (do this only if you want to hide this part)

    * If you get the answer then mark as 'Correct '.

  • Dynamic WHERE Clause with multiple ORs

    I need to build a dynamic SQL statement such as the clause WHERE looks / works as follows:

    WHERE x LIKE '%1% ' OR LIKE '%2% ' x OR x LIKE '%3%...

    I can do the above, no problem, but I wonder if there is a better way?

    Thank you

    Mark

    Hi, Mark,.

    You should not need dynamic SQL for that.

    For example, if you are still interested in substrings of characters suingle, and you get entry as a unique string called str (e.g. '123' it which means you want to find the rows where x contains '1', '2' or 3'), so you could say:

    ...

    WHERE (x REGEXP_LIKE

    , '[' || str || ']'

    )

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and INSERT statements), a few entries and also post the desired results of each input given the same data.
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

  • REPORT: dynamic where

    Hello

    problem:

    According to the page I land current page 'WHERE' of the SQL query condition in gear changes.

    For example:

    If I come to page 1, my sql is:

    [code]

    Select col1, col2

    FROM table1

    where col3 'SOMETHING' <>and

    COL 4 = "FOO";

    [/ code]

    If I come to page 2, my

    My sql is:

    [code]

    Select col1, col2

    FROM table1

    where col3 <>'SOMETHING ';

    [/ code]

    the report columns have links, and I think it will be a lot of pain to redo everything only programmatically.

    Question:

    is there a way to achieve such a feature?

    Hello

    Select query SQL as Source and white PLSQL code as shown in the example that you have found.

    After creating the report, it will look like this

    Concerning

  • Dynamic where clause

    Hello
    I have a table named TEST_TAB that has three columns - COL1, COL2 and COL3.
    COL3 PEUVENT having distinct values of 1,2 and 3.
    I need select * from TEST_TAB following conditions.

    If COL3 has values 1,2 and 3 and select * should return only the rows with COL3 = 1.
    If COL3 has no values 1, then select * should return only the rows with COL3 = 2.
    IF COL3 is either 1 or 2, then select * should return only the rows with COL3 = 3.

    Is it possible to do in a SQL? I prefer a single SQL.

    Thank you.
    Sajeeva Lacotte.

    Something like

    select *
    from TEST_TAB
    where ( COL3 = 1
          or ( COL3 = 2 and not exists ( select null from TEST_TAB where col3 = 1 ) )
          or ( COL3 = 3 and not exists ( select null from TEST_TAB where col3 in ( 1, 2 ) ) )
          )        
    

    Anton

  • How to dynamically generate where clause in Linq

    Hi all


    Oracle DB: 11 gR 2
    Oracle Client: 11.2.0.3.0 (ODP.NET)
    Oracle Developer Tools for Visual Studio
    VS 2010 (C#)

    In a Windows Form, it must query the data based on the values in list dropdown listboxes, which the user selects.
    Let's say two combox, one Department and one for salary
    Department:
    -1 all the
    10 Department 1
    20 Department 2
    30 Department 3

    Salary:
    -1 all the
    1 < 20000
    2 20000 to 50000
    3 50000 to 100000
    4 > 100000


    Here is the c# code to query data:
    using (var myEDMctx = new HREntities())
    {
    var LINQrslt = from emp in myEDMctx.EMPLOYEES
    Select emp;

    }


    The default values for the two combox should be everything.
    How to write dynamic where clause for this LINQ?

    Thanks in advance!

    That's what I do.

    var query = from c in customers
    Select c;

    If (where1 > - 1).
    Query = query. Where(c.Where1 > where1);

    If (where2 > - 1).
    Query = query. Where(c.where2 == where2);

    to return the query;

    Published by: Invincible on July 4, 2012 09:25

    Published by: Invincible on July 4, 2012 09:27

  • Report interactive get where clause and change

    Hello

    If it is possible at the Apex 4.2 get interactive report where clause and change before Notre Dame for example result

    We have a report and some of the columns we should exactly match and for some partial matching.

    And the requirement of the company, they can't add % extra to the and of the search string. It should be added automatically for certain fields.

    Thank you.

    If it is possible at the Apex 4.2 get interactive report where clause and change before Notre Dame for example result

    Get it? Yes. Change it? N °

    We have a report and some of the columns we should exactly match and for some partial matching.

    And the requirement of the company, they can't add % extra to the and of the search string. It should be added automatically for certain fields.

    Teach the company how to use the tools at their disposal. Quick filters use the default search "contains", while the more specific filters are accessible through actions > filters.

    You still use IR filters? When you do a quick search (with or without a selected column), then a contains the will find the occurrence of the entered string regardless of its position (starts with, ends with).

    If you use page elements to filter, then you can easily add the % to these clauses, no?

  • Interactive report case triggering a dynamic action

    Hello

    My interactive report is built, based on the following query

    SELECT ID_OPERACION, NOMBRE_CLIENTE, TOTAL_PAGAR, APEX_ITEM. CHECKBOX (1, O.ID_OPERACION, "onclick ="f_UpdateCollection (this)"', a.c001") "Seleccionar"

    OPERACIONES o, apex_collections a

    WHERE the a.c001 (+) = O.ID_OPERACION

    and a.collection_name (+) = "OPE_COLLECTION".


    I use a collection because I don't want to lose the selected controls caused by paging.


    I would like to add a dynamic action that each time check box is selected, an element (P5_TOTAL_SELECCIONADO) summarizes the column TOTAL_PAGAR of all the checkboxes that are selected and each time a checkbox is unchecked the Total_seleccionado subtracts the value of the selected item.


    How can I do?

    Hi Eva,

    Please check again your application and see if it's what you thought.

    I made a few changes. First, here you were talking about P5_... the elements in your workspace apex.oracle, the page number is 1, so I changed the P5_... elements of P1_...

    Then, you let the fire on the boxes page laod on, but you don't want t function to begin to evaluate during page loading.

    There were also a few errors in the javascript code, I suggested. The VALOR_PAGAR selector was not correct, I've changed a little bit. Also all selected text values are strings and adding javascript strings will be just concatonate them. I made string number conversion for you, also taken into account that null values (P1_TOTAL_SELECCIONADO on page loading is null) cannot be cast to number.

    The result is:

    var VALOR_PAGAR = $(this.triggeringElement).closest('tr') .find ('td [headers = "VALOR_PAGAR"]') .text)

    var TOTAL_SELECCIONADO = $v ('P1_TOTAL_SELECCIONADO')

    VALOR_PAGAR = (isNaN (parseInt (VALOR_PAGAR) = VALOR_PAGAR)? 0: VALOR_PAGAR)

    TOTAL_SELECCIONADO = (isNaN (parseInt (TOTAL_SELECCIONADO) = TOTAL_SELECCIONADO)? 0: TOTAL_SELECCIONADO)

    var total = VALOR_PAGAR + TOTAL_SELECCIONADO

    $s ('P1_TOTAL_SELECCIONADO', total)

    This is the code to add checkboxes checked, false action is the same except for total, which is:

    var total = VALOR_PAGAR - TOTAL_SELECCIONADO

    Kind regards

    Vincent

  • Dynamic action with refreshment area interactive report

    Hello!

    I use APEX 4.02

    I have a page with 2 regions.
    Region1 is a form (of entry)
    Region.2 is an interactive report on the same table as region 1

    When you enter values in the form I'm trying dynmically similar research records in the table with the interactive report.

    I made a dynamic action on the change of form fields that must refresh the interactive report region. I can see this one fires if I add an alert to debug if it fires.
    The dynamic report is based on a query with bind variable pointing to the fields in the form, for example
    where
    Field1 =: P2_FIELD1


    It works fine on the page loading, so no action is triggered, but I see the lines in the region of report are the ones I'm looking for.
    The updating of the report area does not work, but it is never nice and/or showing the correct data after a change of form fields, if it looks like the dynamic action "refresh the region" does not work on the interactive report.

    Any ideas why it can go wrong?
    I want to solve this problem using standard dynamic actions and preferably not via PL/SQL or JS, should be possible if I believe documentation... ;)

    See you soon
    Bottom

    Published by: bklerk on 26-apr-2011 03:07

    Hello

    Check this example application
    http://Apex.Oracle.com/pls/OTN/f?p=39830:38

    You can download and check the source

    Kind regards
    Jari

Maybe you are looking for

  • Access97 Installationsur M40X-112

    Hello together, I have some problems with msaccess97 on my new M40X-112. Failed to install the software (office97). ACCESS failed with an error called "zuwenig Arbeitspseicher" insuficient memory. Wow, the Machine has 1 GB of memory on board. My suge

  • Vista Home Premium Screensaver Aurora and the energy of Windows

    Since 3 weeks I have had really bad luck with 2 of your screensavers and my 4 graphics cards. I'm not sure what kind of screensavers guys do but 2 named Aurora and Windows energy should never have been released to the public without testing, includin

  • Update Windows problem and no sound.

    I have Windows 7 64 bit. Windows Update tells me to restart to complete the installation of updates. I did this several times and spent hours searching for the answer online. I have also no sound. Evrything is activated and it says device high defini

  • Increase the size of text ONLY?

    Is it possible to increase the size of world police ONLY? This question was asked several times on this forum and has always answered using the global DPI setting of the system. This isn't the answer I'm looking for. I just want to set the overall FO

  • Event viewer errors

    I had the best ever win 7 own reinstalling. not an error or a warning, but event viewer shows me 85 errors and warnings. WHY?