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

Tags: Java

Similar Questions

  • How to use a function in a Where Clause?

    Hello
    I have a doubt. If MY_FUNCT is a function that returns a Boolean value, can I use in a where clause clause to write a query like this? :

    Select...
    table one
    where the...
    *...*
    and MY_FUNC (a.field) = true
    *...*
    *;*

    Thank you!

    Published by: Mark1970 on 3.27 lug-2-2010

    But is it possible that the function does not return a Boolean value?

    Yes (as sysdate, substr and instr etc.) you can also use your own function in a where clause clause, as long as it does not return a BOOLEAN value.

    I mean how to use a function in a where clause clause?

    Your own pseudocode seems a good example for me.
    So, just give it a try.

  • How to set sql server date has time format

    Dear Sir.

    I used the windows 7 operating system.

    I have work on scada software to explore siemens wincc.

    I develop the report based on sql server work.

    but the problem is when I put my system date in DDMMYYYY format, so my data was not stored in sql server.

    but when

    I put my system date in YYYYMMDD format, then my data stored in sql server.

    so, how to change the date format sql server.

    I am attaching screenshot (it is a red box, so this date format, I held DDMMYYYY)

    Please give solution.

    Abhijit Hello,

    Thank you for visiting Microsoft Community and we provide a detailed description of the issue.

    According to the description, I understand that you have a question setting SQL server date time format. When you try to set the system date format id ddmmy, the data are not stored in SQL server on the system.

    To get more information about it, we have a dedicated forum where these issues are dealt with and would be better suited to the TechNet community.

    Please visit the link below to find a community that will provide the best support.

    https://social.technet.Microsoft.com/search/en-us/TechNet?query=SQL%20server&beta=0&AC=4#refinementChanges=129&PageNumber=1&showMore=false

    I hope this information is useful.

    Please let us know if you need more help, we will be happy to help you.

    Thank you.

  • How to set background for container

    I want to do two things:

    (1) to set the background of a container like a solid color

    (2) set the background of a container like a png image

    How this is done? I'm going crazy over this. In android and and regular development of bb is so simple.

    Help, please.

    Hey shethab,

    Don't sweat it that we have all been there! Here's how you set the background color of your application. Where there are two ways:

    First define the metadata to a background color like this:

    package{   import flash.display.Sprite;
    
      [SWF(width="1024", height="600", backgroundColor="#CCCCCC", frameRate="30")] public class MyApplication extends Sprite
    
          public function MyApplication()       {         (...)
    
          } }}
    

    The background is in the same format as the color of the HTML. The second way is by creating a shape object that is larger than the screen and adding that the first child in your program as follows:

    package{   import flash.display.Shape;   import flash.display.Sprite;
    
        [SWF(width="1024", height="600", backgroundColor="#CCCCCC", frameRate="30")]  public class MyApplication extends Sprite {         public function MyApplication()       {
    
              var appBackgroundColor:Shape = new Shape();
    
              appBackgroundColor.graphics.beginFill(0xFF0000);          appBackgroundColor.graphics.drawRect(0,0,1024,600);           appBackgroundColor.graphics.endFill();
    
              addChild(appBackgroundColor);
    
                (...)     } }}
    

    To add an image is as the second step only by using the Image class as follows:

    package
    {
        import flash.display.Shape;
        import flash.display.Sprite;
        import flash.filesystem.File;
    
        import qnx.ui.display.Image;
    
        [SWF(width="1024", height="600", backgroundColor="#CCCCCC", frameRate="30")]
        public class MyApplication extends Sprite
        {
            public function MyApplication()
            {
    
                var appBackgroundImage:Image = new Image();
    
                appBackgroundImage.setImage(File.applicationDirectory.resolvePath('path/to/image.png').url);
                appBackgroundImage.setSize(1024,600);
                appBackgroundImage.setPosition(0,0);
    
                addChild(appBackgroundImage);
    
                (...)
    
            }
        }
    }
    

    hope that helps! Good luck!

  • How to get SQL that do not use bind variables

    Hello

    I am trying to identify the SQL code which should benefit from the use of bind variables.
    First of all, I tried to get the common signature of all the sql calls, using:
    select * from (
    select  force_matching_signature, count(1) from v$sql where force_matching_signature<>0 group by force_matching_signature order by 2 desc
    ) where rownum < 50;
    Then I copied these values to the Clipboard and run:
    select sql_text from v$sql where force_matching_signature=<<<copied_signature_value>>>;
    Now, I want to make it automatically and get only 1 occurrence of each SQL that resembles others by using a query.

    I tried this:
    select sql_text from
    (
    select sql_text, force_matching_signature, row_number() over (partition by force_matching_signature order by sql_text desc)rn from v$sql where force_matching_signature <>0
    )where rn <2 and rownum < 10 order by force_matching_signature desc
    But it is not returning results by showing up at the count (1) from the first query, I've used. How can I change this if I get the results in order of "importance"?




    Thank you

    And I said. First use the command by then use rownum. I did not mention row_number. Also, there should be no need to add more columns.
    Have you tried it? Why it did not work?

    example not tested

    select * from (
       select sql_text from (select sql_text, force_matching_signature, row_number() over (partition by force_matching_signature order by sql_text desc) rn from v$sql where force_matching_signature != 0)
       where rn = 1
       order by force_matching_signature desc /* add any ordering you like here */
       )
    where rownum < 10  /* then filter on the first 10 results */
    

    If you want to order that the statement that found most of the time comes first, say so. However, I don't see how to group in your case.
    Maybe like this

    example of tested

    select * from (
       select cnt, sql_text
       from (select sql_text, force_matching_signature, row_number() over (partition by force_matching_signature order by sql_text desc) rn , count(*) over (partition by force_matching_signature) cnt
             from v$sql
             where force_matching_signature != 0)
       where rn = 1
       order by cnt desc, force_matching_signature desc /* add any ordering you like here */
       )
    where rownum < 10  /* then filter on the first 10 results */
    ;
    

    Published by: Sven w. October 11, 2012 14:49

    Published by: Sven w. October 11, 2012 14:51

    Published by: Sven w. on October 11, 2012 14:56 - number column added to the output

  • How to use the instruction box in where clause

    Hi all


    I need to use cases where clause guide me please how I can do it.


    AND WHEN BOX: KAPCO = "KAPCO" THEN cla. CLASS_NAME LIKE '% KAPCO % '.
    WHEN: KAPCO = "NON_KAPCO" THEN SUPERIOR (cla. CLASS_NAME) NOT LIKE '% KAPCO % '.
    WHEN: KAPCO = 'ALL' GOLD: KAPCO IS NULL SO SUPERIOR (cla. CLASS_NAME) LIKE '% '.
    END



    Concerning

    Published by: user10941925 on March 4, 2012 22:31

    Hello

    CASE expressions return a single value, for example a VARCHAR2. They do refer to code fragments.

    You usually don't need (or want) an expression BOX in a WHERE clause, or any other condition. I think that you were trying to do the equivalent of:

    AND     (     (:KAPCO = 'KAPCO'          AND cla.CLASS_NAME       LIKE '%KAPCO%')     -- Don't you want UPPER on this line?
         OR     (:KAPCO = 'NON_KAPCO'           AND UPPER(cla.CLASS_NAME) NOT LIKE '%KAPCO%')
         OR     (NVL (:KAPCO, 'ALL') = 'ALL'       AND cla.CLASS_NAME IS NOT NULL)
         )
    

    If you would care to post some sample data (CREATE TABLE and INSERT statements) and the results desired from this data, I was able to test this.

  • How to pass a value LOV to where clause of another LOV

    Hello

    I have the two LOV project and activity. When I select a value of project LOV this value project to switch to the 2nd activity LOV where clause. How can I achieve this.

    I tried to use the code in the process CO request by getting the value of project with the command below.

    int v_project = Integer.parseInt ((String) passiveCriteria.get ('Project')); grab the critirea project

    and set this value in the setwhereclauseparams of the VO LOV. But the above command is throwing an exception with the exception of null pointer.

    This approach is correct, or should I use any other method.

    Thank you
    HC

    Below you will find the article interesting

    http://oracleanil.blogspot.com/2010/12/dependent-lov-in-OAF.html

    Thank you
    AJ

  • How to filter the result with a where clause clause?

    Hello

    I have a nice sql query. I would like to include a where clause with a joker clause.

    If the user selects for example a "AGENT_ID", then where clause would include the AGENT_ID, otherwise, every thing would appear.
    SELECT 
       "FICHE"."FICHE_ID" "FICHE_ID", 
       "FICHE"."AGENT_ID" "AGENT_ID", 
       "FICHE"."EQUIPE_ID" "EQUIPE_ID", 
       "FICHE"."DATE_ACTIVITE" "DATE_ACTIVITE", 
       "FICHE"."DATE_CREATION" "DATE_CREATION", 
       "FICHE"."TYPE_FICHE" "TYPE_FICHE", 
       "FICHE"."FICHE_CREE_PAR" "FICHE_CREE_PAR", 
       "FICHE"."TOTAL_HEURES" "TOTAL_HEURES", 
       "FICHE"."TOTAL_HEURES_EXCEPTIONNELLES" "TOTAL_HEURES_EXCEPTIONNELLES", 
       "FICHE"."DATE_MODIFICATION" "DATE_MODIFICATION"
    FROM 
       "FICHE"
    The WHERE clause:
    WHERE AGENT_ID = ' * ' if nothing is selected.

    WHERE AGENT_ID = "4290" If an agent ID is selected.

    Hope I'm clear that English is not my mother tongue.

    Thanks for you help.

    Christian

    Hello

    Try this

    WHERE "FICHE".AGENT_ID like NVL(:val, '%')
    

    see you soon

    VT

  • How can I extract a substring in WHERE Clause &lt; CFQUERY &gt;?

    Is it possible to extract a substring in the WHERE clause of either < CFQUERY > or in a query of queries?  I try to use the following query to find all e-mail addresses with the domain "comcast.net" (i.e., everything that follows the '@' in the email address).  I ask an MS-Access database table.

    < cfquery name='test' datasource='membership'>
    SELECT Email_address
    OF tblMembers
    WHERE the MID (email_address, INSTR (email_address, ' @') + 1) = "comcast.net"
    < / cfquery >


    If I try this as a query, I get the error message "[Macromedia] [SequeLink JDBC Driver] [ODBC Socket] [Microsoft] [ODBC Microsoft Access driver] data type incompatible in criteria expression."


    If I try it as a t/t, I get the error message " " Met 'MID (e-mail1.,. Incorrect conditional expression, waiting for one of [as | null | between | in | comparison] condition,'.

    I would be very grateful for any help on finding something that works!  Thanks for your help!


    You couldn't do a LIKE in where clause instead:

    SELECT Email_address

    OF tblMembers

    WHERE email_address LIKE ' %@comcast.net'

    You should get the addresses you're looking for.

    -Carl V.

  • How to save pdf that contains pantone colors properly?

    Hello everyone. Here's the problem:

    I usually do my work in CMYK, but one of the concepts of my client require two Pantone colors. I use the Pantone swatch library colors and save as pdf print ready file. But, after sending a file to typography, I get my file back with the message that there is no Pantone colors - I have used CMYK. I don't convert all colors to CMYK before save, I googled on this topic and I'm sure I did everything right. I called guy of typography, and he told me how to convert Pantone colors. I did as he told me, but the result is always the same: Pantone colors went to the final pdf format. Is it possible, after registration in pdf format there is somewhere in the checkbox, which converts all colors to CMYK? Because I do other work for this client, I don't want to deal with this problem once again - so if anyone has an idea, what the problem is, I'll be very grateful for your answers.f this issue

    Thank you

    What book color did you use? Not the process that I hope. If so, that's the problem.

  • [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 does set a printer 'active' in LabVIEW?

    The method PrintPanel for a VI says that it will print to the printer 'current '.  How does set a that?

    On Windows, all applications start with the default printer and the user can change this to be the "current printer"

    but it's different in each application.

    LabVIEW does seem to have no way to set the current printer until it is needed?

    And why can't the method takes a name of the printer in option though?

    I think you're looking the printingefault printer property for the Application class.

  • 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);
        }
    
  • How only include a WHERE clause only when a connection variable has a value?

    I use JDeveloper 11 g using business components of the tables. I'm now modify the auto-generated SQL code to include WHERE clauses which depend on the values of bind variables. For example I have something like this:
    SELECT mytable.firstColumn
    FROM myTable 
    WHERE myTable.secondColumn= :VariableValue
    However, this means that when VariableValue is null SQL would fail and I get an error. Is there a way I can include the WHERE clause (or clause AND according to the position in SQL) only when a bound variable has a value (or a particular value)?

    Or use: WHERE NVL(:VariableValue,myTable.secondColumn) = myTable.secondColumn

  • alias in where clause

    Hello

    It is a question of OCA certification.

    1. SQL > SELECT prod_name, prod_list_price, prod_list_price-(prod_list_price*.25) "DISCOUNTED_PRICE".
    PRODUCTS
    WHERE the discounted_price < 10;

    The query generates an error.
    What is the reason for generating fault?
    A. the parentheses should be added to frame the entire expression
    B. the quotes should be removed from the column alias
    C. column aliases must be replaced by the expression in the WHERE clause
    D. column aliases must be capitalized and closed double quotes in the WHERE clause

    Answer: D


    My question is how we can use aliases ("DISCOUNTED_PRICE") in where clause (WHERE "DISCOUNTED_PRICE" < 10)?

    Please specify.

    Hello

    C. response (and I think, you not write review at this time)

    You cannot use alias name in the WHERE clause.

    And if you want to continue to use DISCOUNTED_PRICE in the WHERE clause, you can use view inline.

    SELECT *
    FROM (SELECT prod_name,prod_list_price,prod_list_price-(prod_list_price*.25) "DISCOUNTED_PRICE"
    FROM products
    )
    WHERE  WHERE discounted_price<10;
    

    See you soon,.
    Suri

Maybe you are looking for