ViewObject where Clause SET based on logged in user roles

Hello Experts

I have a view object based on a custom query to get distinct values from a table. My requirement is to display the results as a listview. The listview is is filled without any problem. But I need to add a where clause clause the object view based on the user roles.

I have a method that generates the where clause and returns one string something like "COUNTRIES ('USA', 'UK').

I created a class of the view object Impl and put WhereClause as below: but where clause is not applied when I run the page. I see everywhere instead of just USA & UK.

Can you let me know at what time should I set the where the clause?

SerializableAttribute public class CountriesVOImpl extends ViewObjectImpl {}

/**

* This is the default constructor (do not remove).

*/

public CountriesVOImpl () {}

this.setWhereClause (getCountries ());

}

public String getCountries() {}

return '('USA', 'UK') COUNTRIES. "

}

}

In class ViewImpl try to replace "executeQueryForCollection" and setWhereClause in this function as:

    protected void executeQueryForCollection(Object object, Object[] object2, int i)
    {
        setWhereClause("COUNTRY in ('USA','UK')");
        super.executeQueryForCollection(object, object2, i);
    }

Tags: Java

Similar Questions

  • [ADF, JDev12.1.3] How to set a variable to bind a VO (where clause) in a managed bean?

    Hallo,

    I have a request based on VO.

    The query contains a where clause clause and a bindi variable.

    In a managed bean I would like to access the iterator of VO setting the value of the bind variable and read the result.

    I found this code it is good start, but I do not know how to set the variable binding.

    BindingContext bctx = BindingContext.getCurrent();
    BindingContainer bindings = bctx.getCurrentBindingsEntry();
    DCIteratorBinding iter = (DCIteratorBinding ) bindings.get("MyVO1Iterator");
    iter.execute();
    
    
    

    You kindly help me?

    Also, I would like to know if it is generally advisable to use VO directly in controlled beans or whether it would be best to create in the AppModuleImpl methods that do this and return the result.

    In my case for example of the VO will return max 1 plug so I'm in doubt, if the creation of a method in the AM that returns a custom class, which attributes contain values of the line of VO.

    Sorry if these questions may seem artificial, but I am a beginner, I have many doubts and so I would be happy to receive some tips regarding best practices.

    Thank you

    Federico

    You can use:

    iter.getViewObject().setNamedWhereClauseParam("yourBindVar", value);
    

    Note that this approach is used if you have bind variable in the where clause.

    To set variables bind to ViewCriteria, you must use VarableValueManager.

    This post may be useful for you: binary: how to set the Bind variable values at run time?

    Also, I would like to know if it is generally advisable to use VO directly in controlled beans or whether it would be best to create in the AppModuleImpl methods that do this and return the result.

    You must set "use VO directly.

    For example, from the point of architecture, is probably best to use the method in the model project which will set the bind variable and execute the query.

    Or you can use the ExecuteWithParams operation in your the view layer.

    In my case for example of the VO will return max 1 plug so I'm in doubt, if the creation of a method in the AM that returns a custom class, which attributes contain values of the line of VO.

    Not to complicate your life

    All VO lines are represented as ViewRowImpl class if you already have "custom class".

    Finally, you can generate your own ViewRowImpl class if it is necessary for this.

    Dario

  • How to set a null column in a where clause clause involving a statement box

    In oracle APEX, I a (selection list) element called: P32_STATUS. It contains two values of interest (for this discussion): 'Available' and 'checked '. In my report, I have a column called vc_status that contains two values: "Checkbox" and NULL. In my application I want to use a case statement in my where clause similar to the lines of

    where

    .

    .

    .

    AND (vc_status = CASE WHEN: P32_STATUS = "Checkbox" THEN : P32_STATUS )

    WHEN : P32_STATUS = 'Available' THEN NULL END)

    The 'box' filtering works but the filtering to try to vc_status the NULL value does not work. Can someone help me? Thank you!

    (P.S. My intuition says that there because I can not put vc_status = NULL, but I must say that vc_status IS NULL... However, I don't know how to do execution IS ZERO inside a CASE statement)

    Hello

    Your intuition is right...

    In Oracle NULL is a bit special:

    NULL = NULL is false

    NULL <> NULL is false

    Thus, instead of the parameter a NULL value in the CASE WHERE there is just set a value on the other side:

    NVL (vc_statut, 'Available') =: P32_STATUS

    That's all! Simple, clean and functional

  • How to set SQL that contains 'in' where clause in VO?

    I don't want to set "in" would adopt a kind of programatical in VO as below. I want to use a method declariable to set in the clause using bindings varaible.

    It can be implemented?

        private String getInClauseWithParamNames(List termCodes) {
               //logic to form the in clause with multiple bind variables
               StringBuffer inClause = new StringBuffer(); 
               if(termCodes !=null){
                   for (int i = 1; i < termCodes.size() + 1; i++) { 
                       inClause.append(":termC" + (i));
                       if (i < termCodes.size()) { 
                          inClause.append(","); 
                       } 
                   }
               }
               return inClause.toString();
        }
            
        public Row[] getYardFixedSlots(List termCodes) {
            if(termCodes != null && !termCodes.isEmpty()){
                String inClause = getInClauseWithParamNames(termCodes);
                //setting the where cluase to use the generated in clause
                this.setWhereClause("YardFixedSlot.TERMINAL_C in (" + inClause + ")");
                ////clearing all existing where clause params if any 
                this.setWhereClauseParams(null);
                if(getVariableManager() !=null){
                   this.getVariableManager().clearVariables();
                }
                //setting values for all bind variables one by one in the in clause
                for (int i = 0; i < termCodes.size(); i++) { 
                    //defining the named bind variables programatically 
                    this.defineNamedWhereClauseParam("termC" + (i + 1), null, null);
                    //setting the value for each named bind variable 
                    this.setNamedWhereClauseParam("termC" + (i + 1), termCodes.get(i)); 
                }
                this.setRangeSize(-1); 
                //executing the query 
                this.executeQuery(); 
            }
            //returning the rows from query result 
            return this.getAllRowsInRange(); 
        }
    

    You can only use the link as a parameter to the in clause. You must divide the string inside the binding variable. Sample can be found at decompilation binary ADF: using bind variable for SQL statements with the paragraph

    Timo

  • 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

  • Where clause in a stored procedure based Datablock

    I have a datablock based on a stored procedure but the where clause doesn't seem to work.

    Even if I put where clause in the block properties, it still returns all records when I do an execute_query.

    Anyone else had this kind of problem?

    Thanks in advance

    Hello

    This is how I do the trick:

      ----------------------------
      --  Select with REFCURSOR --
      ----------------------------
      PROCEDURE emp_refcur
        (
             emp_data IN OUT emp_cursor
            ,p_num IN VARCHAR2
            ,p_nom IN VARCHAR2
            ,p_job IN VARCHAR2
            ,p_sal IN VARCHAR2
            ,p_com IN VARCHAR2
          ) IS
      BEGIN
        -- backup where clause --
         GC$Num := p_num ;
         GC$Nom := p_nom ;
         GC$Job := p_job ;
         GC$Sal := p_sal ;
         GC$Com := p_com ;
    
         OPEN  emp_data FOR SELECT empno, ename, job, sal, comm
         FROM  emp
         WHERE EMPNO LIKE Nvl( p_num || '%', EMPNO )
         AND   ENAME LIKE Nvl( p_nom || '%', ENAME )
         AND   JOB LIKE Nvl( p_job || '%', JOB )
         AND   ( SAL LIKE Nvl( p_sal || '%', SAL ) OR p_sal is null )
         AND   ( COMM LIKE Nvl( p_com || '%', COMM ) OR p_com is null )
         ORDER BY ENAME ;
      END emp_refcur;
    

    François

  • dynamic logic in SQL WHERE clause based on the value of the ELEMENT

    Hello

    I have a report based on the following SQL query.
       select dept_no,
           dept_name,
           dept_loc
      from dept
     where dept_loc = :P1_DEPT_LOC
       // If P1_DEPT_LOC is not null, I want the WHERE clause and IF  P1_DEPT_LOC is null, then I don't need the WHERE clause.
       // how can I build this logic in same SQL
    Thank you
    Deepak

    Published by: Deepak_J on March 11, 2010 16:37

    where: P1_DEPT_LOC IS NULL or dept_loc =: P1_DEPT_LOC

    If dept_loc is not null better would be

    where dept_loc = coalesce(:P1_DEPT_LOC,dept_loc)

  • Setting of outsourcing work is not for a SQL Where clause

    Im trying to outsource the WHERE SQL clause of a snapshot data (connecting to Siebel DB) and specify where clause in the run profile that does not work.

    Snapshot of research: Select the name of siebel.s_org_ext

    Parameter of outsourcing: where_clause_sql

    Run the content of the profile:

    phase. Phase1.snapshot.clt.where_clause_sql = name = "ABC0009".

    #phase. Phase1.snapshot.clt.snapshot_sql = select name from siebel.s_org_ext where name = 'ABC0009 '.

    The above parameter retrieves all the records in the table. Below the profile execution retrieves just this record that seems to work fine.


    Run the content of the profile:

    phase. Phase1.snapshot.clt.snapshot_sql = select name from siebel.s_org_ext where name = 'ABC0009 '.


    I want to outsource only where clause as there are many SQL and they are huge to maintain in the run profile.

    I have attached a doco with screenshots that will help to understand more.

    Hello

    You must BE

    -Choose "Select table or view" in the table of the snapshot Wizard selection page

    &

    -Use outsourced where clause

    OR

    -Choose "SQL" in the snapshot table selection wizard page.

    &

    -Outsourced use SQL snapshot

    You can't mix and match options.

    Kind regards

    Nick

  • Need a set or a where clause

    SELECT
    C.CUSTOMER_NUM,
    C.CUSTOMER_NAME,
    C.STREET,
    C.CITY,
    C.STATE,
    C.ZIP,
    C.BALANCE,
    C.CREDIT_LIMIT,
    C.REP_NUM,
    (CREDIT_LIMIT - BALANCE) AVAILABLE_BALANCE,
    (SELECT First_Name |) » '|| Last_name FROM PP_REP WHERE REP_NUM = C.REP_NUM) REP_NAME
    OF PP_CUSTOMER C
    WHERE C.REP_NUM =: P3_REP_NUM;

    I need to change the place where clause in the order so that if - 1 is received it displays all PP_CUSTOMER, but if it receives any other REP_NUM it displays PP_CUSTOMERS with this REP_NUM.

    I tried a lot of solutions to the frustrations.

    Hello

    Try this:

    SELECT
     C.CUSTOMER_NUM,
     C.CUSTOMER_NAME,
     C.STREET,
     C.CITY,
     C.STATE,
     C.ZIP,
     C.BALANCE,
     C.CREDIT_LIMIT,
     C.REP_NUM,
     (CREDIT_LIMIT - BALANCE) AVAILABLE_BALANCE,
     (SELECT First_Name||' '||Last_name FROM PP_REP WHERE REP_NUM = C.REP_NUM) REP_NAME
     FROM PP_CUSTOMER C
     WHERE C.REP_NUM = decode(:P3_REP_NUM, -1, C.REP_NUM, :P3_REP_NUM);
    

    Kind regards
    Dirk

  • Setting in the WHERE clause of the query

    Hi all

    I have 2 tables.

    TABLE_A contains 10 million documents.
    TABLE_B contains 100 records.

    I associate myself with these 2 tables

    Here's a.ID left
    SELECT A.*, B.*
    FROM TABLE_A a, TABLE_B b
    WHERE a.ID = b.ID;
    Here's b.ID left
    SELECT A.*, B.*
    FROM TABLE_A a, TABLE_B b
    WHERE b.ID = a.ID;
    My question is what query will give better performance? I thought that, if we put the column in the table with a lower number of lines on the left, then it will be faster than the other.

    In current versions of Oracle, it does not matter in what order you sum-up your predicates in the WHERE clause of a query: they will be optimized/executed in a way even.

  • Question about the order of evaluation of the clause WHERE CLAUSE when the Oracle OF the syntax used to join tables

    Hello

    Oracle version: 11.1.0.7.0 - 64 bit

    I read the documentation online at joins. The page is avialable here: joins at

    My question is about the join order of evaluation of the conditions in clause and the conditions of those

    are not the join conditions and are placed in the WHERE clause.

    Consider the following pseudocode

    SELECT

    T1. Col1,

    T2.Col1

    Of

    Table1 t1 LEFT OUTER JOIN table2 t2

    WE

    (condition_expression1)

    WHERE

    (condition_expression2)

    Is it correct to say that if there is no column on the status of join (condition_expression1) in condition_expression2, then condition_expression2 is executed before condition_expression1? In other words, oracle always trying to filter based on the WHERE clause individually each table as much as possible before joining them based on the conditions on the article?

    Thanks in advance,

    Hello

    dariyoosh wrote:

    Hello

    Oracle version: 11.1.0.7.0 - 64 bit

    I read the documentation online at joins. The page is avialable here: joins at

    My question is about the join order of evaluation of the conditions in clause and the conditions of those

    are not the join conditions and are placed in the WHERE clause.

    Consider the following pseudocode

    SELECT

    T1. Col1,

    T2.Col1

    Of

    Table1 t1 LEFT OUTER JOIN table2 t2

    WE

    (condition_expression1)

    WHERE

    (condition_expression2)

    Is it correct to say that if there is no column on the status of join (condition_expression1) in condition_expression2, then condition_expression2 is executed before condition_expression1? In other words, oracle always trying to filter based on the WHERE clause individually each table as much as possible before joining them based on the conditions on the article? ...

    The reverse is actually closer to the truth, but we can't really make general statements like that.

    SQL is not a language of the proceedings.  Looking at the code SQL, we could say that the code does, but we cannot say much about how that code it.  In other words, SQL is a language that describes the results you get, not the way to get them.

    The optimizer will do everything what he thinks is faster if it does not change the results.  If any order in which they are applied (in outer joins or CONNECT BY queries, for example), then think of the join is done first, and the value of the WHERE clause is applied to the result of the join.

    Here is a query looks very much like you posted:

    SELECT d.deptno

    e.ename, e.sal

    OF scott.dept d

    LEFT OUTER JOIN scott.emp e ON e.deptno = d.deptno

    WHERE e.sal > = 3000

    ORDER BY d.deptno

    ;

    Output:

    DEPTNO ENAME SAL

    ---------- ---------- ----------

    10 KING 5000

    20 FORD 3000

    20 3000 SCOTT

    The scott.dept table contains deptnos 30 and 40; Why are they not in the result set?  The query behaves as if the outer join is made first (production 15 rows), then the WHERE clause has been applied.  All lines with deptno = 30 had sals down han 3000 and all single line with deptno = 40 was NULL in the sal column, then these lines are excluded (as well as other lines of deptnos 10 and 20), and only 3 lines above are left.

  • Export (expdp) with where clause

    Hello gurus,

    I'm trying to export with where clause. I am getting error below.


    Here is my order of export.
    expdp "'/ as sysdba'" tables = USER1.TABLE1 directory=DATA_PUMP dumpfile=TABLE1.dmp logfile=TABLE1.log query= “USER1.TABLE1:where auditdate>'01-JAN-10'”
    Here is the error
    [keeth]DB1 /oracle/data_15/db1> DATA_PUMP dumpfile=TABLE1.dmp logfile=TABLE1.log query= USER1.TABLE1:where auditdate>'01-JAN-10'                    <
    
    Export: Release 11.2.0.3.0 - Production on Tue Mar 26 03:03:26 2013
    
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    Starting "SYS"."SYS_EXPORT_TABLE_03":  "/******** AS SYSDBA" tables=USER1.TABLE1 directory=DATA_PUMP dumpfile=TABLE1.dmp logfile=TABLE1.log query= USER1.TABLE1:where auditdate
    Estimate in progress using BLOCKS method...
    Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
    Total estimation using BLOCKS method: 386 MB
    Processing object type TABLE_EXPORT/TABLE/TABLE
    Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
    Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
    Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
    Processing object type TABLE_EXPORT/TABLE/TRIGGER
    Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
    ORA-31693: Table data object "USER1"."TABLE1" failed to load/unload and is being skipped due to error:
    ORA-00933: SQL command not properly ended
    Master table "SYS"."SYS_EXPORT_TABLE_03" successfully loaded/unloaded
    ******************************************************************************
    Dump file set for SYS.SYS_EXPORT_TABLE_03 is:
      /oracle/data_15/db1/TABLE1.dmp
    Job "SYS"."SYS_EXPORT_TABLE_03" completed with 1 error(s) at 03:03:58
    Version
    SQL> select * from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production

    Hello

    You must use the settings file. Another question, I see you are using 11g. Why don't you use a data pump.?
    Data pump is faster and has more features and that regular improvement imp and exp.

    You can do the following:

    sqlplus / as sysdba
    
    Create directory DPUMP_DIR3  for 'Type here your os path that you want to export to';
    

    then tap on a file:
    Touch par.txt

    In this file, type the following line the following:

    tables=schema.table_name
    dumpfile=yourdump.dmp
    DIRECTORY=DPUMP_DIR3
    logfile=Your_logfile.log
    QUERY =abs.texp:"where hiredate>'01-JAN-13' "
    

    then proceed as follows
    expdp username/password name parfile = 'par.txt'

    You will import to Oracle 11 g to 10g version should add 'version = 10' parameter in the above setting file

    BR
    Mohamed enry
    http://mohamedelazab.blogspot.com/

  • DATAMOVER: Error: syntax error in where clause for PSOPRDEFN

    The VALUE of LOG C:\PSUSER_HRM.log.
    The input VALUE F:\psoprdefn.dat;
    IMPORT psoprdefn where OPRId = 'PS ';

    When I run this command after you import the .dat to my data file, I get error:
    Error: Syntax error in where clause for PSOPRDEFN

    any suggestions pls help...

    Thank you
    Aravind

    Edited by: 967641 on November 20, 2012 11:39

    Edited by: 967641 on November 20, 2012 11:40

    It may or may not be a mistake according to what you're trying to do. He is pretty sure the system to avoid duplication of entries in this table.
    You want to replace data? Remove line import authorization.
    Otherwise, you can set IGNORE_DUPS, it will ignore the duplicated lines to load.

    Nicolas.

  • ADF Faces 11, add where clause to the detail view in the master/detail relationship

    Hello

    I have two display objects only read connected by a link in a relationship master detail.

    They are displayed in a treetable in the form.

    I have a method on the java object impl view master class, I use to add custom where claused based on entries different user and then run the query.

    Works well, master and detail is interview properly.

    But I also want to further filter the detail view (view from destination in the display link). However, as soon as I add whereclause in the detail view against the master
    relationship of detail seems to have disappeared and are no detail record. I also tried to add a view criteria but with the same result.

    Your comments will be appreciated.

    ADF FACES 11g release 1.


    Jan

    You can get the ViewLinkAccessor, then the ViewObject and try to apply the ViewCriteria, followed by executeQuery... what you are already doing.
    Better to paste your code here...

  • Remove the RDF Triple by Sub or predicate or object in where clause

    Hello

    Is it possible to remove a triple based on subject, predicate or object where the terms of the clause?

    If possible please let me know the syntax and example.

    I try with the normal delete his statement ended up with the error.

    I'm not sure of the delete below set out but its not working

    REMOVE THE articles_rdf_data a WHERE clause
    a.triple.get_subject () = '< http://nature.example.com/Article1 >';

    Kind regards
    Kouadio.

    Published by: 789259 on January 18, 2011 01:31

    Yes, when you delete a triple of the table in the application, it gets deleted in the underlying store as well (assuming that no duplicates). You can also check this by running SEM_MATCH query run on the corresponding semantic model before and after the deletion. (For query a semantic model you must have the right to SELECT the corresponding database view).

Maybe you are looking for