Search Query By Example uppercase (value only)

Hello

I use Jdev 11.1.1.6.
I need users to use QBE on table (encapsulated by PanelCollection) using a case-insensitive search.
My application stores all uppercase, so there is no need to put high on the database column. So I'm looking for a solution for only uppercase value entered by the user.

I found an old post from Steve Muench here [http://radio-weblogs.com/0118231/2004/04/16.html#a276]
private void adjustStringViewCriteriaToUppercaseWildcards() {
    ViewCriteria vc = getViewCriteria();
    if (vc != null) {
      ViewCriteriaRow vcr = (ViewCriteriaRow)vc.first();
      AttributeDef[] attrs = vc.getViewObject().getAttributeDefs();
      int attrCount = attrs.length;
      while (vcr != null) {
        for (int z = 0; z < attrCount; z++) {
          if (attrs[z].getSQLType() == Types.VARCHAR ) {
            String criteria = (String)vcr.getAttribute(z);
            if (criteria != null) {
              vcr.setAttribute(z,criteria.toUpperCase()+"%");
            }            
          }
        }
        vcr = (ViewCriteriaRow)vc.next();
      }
    }    
  }
Steve suggested this method in ViewObjectImpl custom and called from getViewCriteriaClause(), something like this:
public String getViewCriteriaClause() {
    adjustEnameViewCriteriaToUppercaseWildcards();
    return super.getViewCriteriaClause();
  }
I noticed that getViewCriteriaClause() has been deprecated in GR 11, 1 material, so instead, I implemented it in getViewCriteriaClause (boolean b).
The problem is that first statement ViewCriteria vc = getViewCriteria(); Returns a null value. My view object doesn't have any criteria in mind. I expect the VC temp which is connected by the framework at QBE.

I modified the code for this:
        ViewCriteria[] vcs = getApplyViewCriterias(ViewCriteria.CRITERIA_MODE_QUERY | ViewCriteria.CRITERIA_MODE_CACHE);
        if (vcs != null && vcs.length > 0) {
            for (ViewCriteria vc : vcs) {
                if (vc != null) {
                    
                    ViewCriteriaRow vcr = (ViewCriteriaRow)vc.first();
                    AttributeDef[] attrs =
                        vc.getViewObject().getAttributeDefs();
                    int attrCount = attrs.length;
                    while (vcr != null) {
                        for (int z = 0; z < attrCount; z++) {
                            if (attrs[z].getSQLType() == Types.VARCHAR) {
                                String criteria = (String)vcr.getAttribute(z);
                                if (criteria != null) {
                                    vcr.setAttribute(z,
                                                     criteria.toUpperCase());
                                }
                            }
                        }
                        vcr = (ViewCriteriaRow)vc.next();
                    }
                }
            }
        }
Now, I see this, it's getting the Victoria Cross and execution of vcr.setAttribute (z, criteria.toUpperCase ()); the value that I got during the search but always matching lines are not retrieved.
When I explicitly put the uppercase value on the UI, then it returns the correct rows.

What I'm doing wrong here? What else do I manage here? Is there another way to make my usecase?

Note: If I do vc.setUpperColumns (true) then it returns all rows corresponding to the search criteria, but the statement is executed with the TOP on both sides where clause, which is the behavior desired, but something that I don't want that it doesn't use any index on this column.

Thank you
JAI

Hi Jai,

You can override the method getCriteriaItemClause (ViewCriteriaItem vci) of ViewObjectImpl, the code should look like this:

@Override
public String getCriteriaItemClause(ViewCriteriaItem vci)
{
  if (vci != null)
  {
    AttributeDef attrDef = vci.getAttributeDef();
    String attrName = attrDef.getName();
    if ("java.lang.String".equals(attrDef.getJavaType().getName()) && vci.getValue() != null)
    {
      String colName = vci.getViewCriteria().isCriteriaForQuery() ? vci.getColumnNameForQuery() : attrName;
      return String.format("(%s = upper('%s'))", colName, vci.getValue());
    }
  }
  return super.getCriteriaItemClause(vci);
}

AP

Tags: Java

Similar Questions

  • Return each value only once using cfloop query

    Hello

    I have a code that fills a cfselect list dynamically and then fills a second list based on these values. Everything seems to work fine, except that all values are taken from the database, and there are duplicates in the majority of cases. For example, the 1S1W is displayed in the dropdown value 10 times, where I'll settle it there once.

    Is it possible to have one of each value in my list?

    < isDefined ('form.select_Main_Group') cfif >

    < cfset page.select_Main_Group = form.select_Main_Group >

    < / cfif >

    < cfoutput >

    < name of the form = "DropDown" method = "post" >

    <!--> query DB for the first descent to the bottom of the list

    < CFQUERY name = "get_Main_Group" datasource = "ds" dbtype = "odbc" >

    SELECT *.

    FROM slco_sire.dbo.area_reference_plats_doc INNER JOIN slco_sire.dbo.area_reference_plats_page

    ON slco_sire.dbo.area_reference_plats_doc.doc_id = slco_sire.dbo.area_reference_plats_page.doc_id

    ORDER BY page_description

    < / CFQUERY >

    <!--> first drop-down list

    <! - VIEW the onChange event of javascript in the select tag, it's what sends the form after the first selection - >

    < select name = "select_Main_Group" required = "yes" onchange = "this.form.submit ()" >

    < option > select Township/range < / option >

    <!-dynamically populate the first drop drop down based on the get_Main_Group query->

    <!-NOTICE the CFIF in the option tag, that said, if the first selection has occurred, display the chosen option when pages are reloaded->

    < cfloop query = "get_Main_Group" >

    < option value = "" #SECTION # "< cfif isDefined ('form.select_Main_Group') > < selected cfif form.select_Main_Group eq ' #SECTION # ' > < / cfif > < / cfif > > #TOWNSHIP_RANGE # < / option >"

    < / cfloop >

    < / select >

    < p >

    <! - if the first selection has been made, see the second dropdown menu with the appropriate results - >

    < isDefined ('page.select_Main_Group') cfif >

    <! - query DB for second drop to the bottom of the list, based on the selected item in the list - >

    < cfquery name = "get_Sub_Group" datasource = "ds" dbtype = "odbc" >

    SELECT TOWNSHIP_RANGE, SECTION

    FROM slco_sire.dbo.area_reference_plats_doc INNER JOIN slco_sire.dbo.area_reference_plats_page

    ON slco_sire.dbo.area_reference_plats_doc.doc_id = slco_sire.dbo.area_reference_plats_page.doc_id

    WHERE the ARTICLE = ' #page.select_Main_Group # '.

    < / cfquery >

    <!--> the second drop down menu

    < select name = "select_Sub_Group" required = "yes" >

    Section select < option > < / option >

    <! - dynamically fill the second fall to the bottom of the list based on the get_Sub_Group query - >

    < cfloop query = "get_Sub_Group" >

    < option value = "#SECTION #" > #SECTION # < / option >

    < / cfloop >

    < / select >

    < / cfif >

    < / make >

    < / cfoutput >

    Emily,

    Easy fix.  Use the same approach you did to determine when the second menu drop-down.  Change this line:

    action = "by_TRS_results_arps_2.cfm" > ""

    to these:

  • How to dynamically change the generated query through the "query by example".

    Hi all. I'm relatively new to the ADF, so I've been beating my head against a wall trying to figure out how to do this... Any help would be greatly appreciated!

    What I try to do is to make a custom search (query) against a set of tables in the database. Normally, I would use just the ability to "filter" the af: table to do this (query by example). However, the query I need to run has three specific requirements:

    1. I need to change the 'WHERE' clause differently according to the field in which the user enters criteria in. For example:
    -If the user enters something in the field 'name' of filter, the default ADF BC will do is add '%' to the value entered, turning it into a query "begins by". I also want to prepend a '%' to the input value, (for example "doe %'), it becomes a query 'contains '. I don't want the user to see the '%', I put at the beginning of the field in the UI, however.
    -If the user enters a value of 9 digits in the field 'SSN', do a query of "accurate". If they penetrate only 4 digits, do a query "ends by". (I could always just a query "ends by" - for example "% of values" - even if they have put in 9 digits, and that would work.) However, an exact match will run faster because of the index on the field, so I want to use that if we put 9-digit.)

    2. I also need to change the SELECT part of the query based on which fields are used in the filter.

    3. If the user enters the filter values in several fields, I need 'OR' them together. The default functionality, it's that they are 'linked' together.

    Can someone point me in the right direction? My thought was somehow replace the manner in which the query is generated when the user presses ENTER to run the filter. But, I can't seem to understand where and how to connect it to this process to customize the SELECTION and WHERE the parts of the generated query. I'm sure that there is a way, and I hope more experienced ADF'ers can direct me to the solution.

    Thank you!

    Published by: 926392 on June 25, 2012 15:39

    Published by: 926392 on June 25, 2012 15:40

    Check this post in the ADF Code corner for the necessary information:
    http://www.Oracle.com/technetwork/developer-tools/ADF/learnmore/30-table-filter-queries-169172.PDF

    Thank you
    Nini

  • tcColumnNotFoundException with the search query

    Hello.

    IM build this search query, but after installing the BP10A I have problems, I get this error in the logs.

    * < 28 October 2010 13:14:07 COT > < opinion > < Stdout > < BEA-000000 > < ERROR, 28 October 2010 13:14:07, 152, [XELLERATE. WEBAPP], class/method: tcLookupFieldAction/selectedValue some problems: {1}. *
    Thor.API.Exceptions.tcColumnNotFoundException

    This is my definition of the search field:
    Name: UD_FVCANAL_PTO_VTA, size = 9

    Properties:
    Column captions: lookupfield.header.lookup_definition.lookup_code_information.decode
    The width of the columns: 9 128
    Column names: LKV_ENCODED, LKV_DECODED
    Lookup column name: LKV_DECODED
    Search query: select 57 as LKV_ENCODED,'$Form data. UD_FVCANAL_CANAL$ ' as the double LKV_DECODED

    Research shows data correctly, but when you select a value, I get a window showing system error and journal reports the message above.

    Am I missing something?

    Thank you.

    Hey people, found this phenomenon was related to a patch BP4 who changed the behavior of the LookupField type. The property "Column names" must now contain only the name of the column used to store the value of the search key in the database.

    In other words both the lookup column name and column names must be on the column that contains the desired value.

    My setup went from this:
    Search query = select usr_login, usr_first_name, usr_last_name, usr
    Lookup column name = usr_login
    The width of the columns = 100,100,100
    Legends of column = User ID, name, first name
    The column names = usr_login, usr_first_name, usr_last_name

    To do this:
    Search query = select usr_login, usr_first_name, usr_last_name, usr
    Lookup column name = usr_login
    The width of the columns = 100,100,100
    Legends of column = User ID, name, first name
    The names of column = usr_login

    My problem is solved.

  • NoSquint resized correctly web pages, but the superior task bars are still too large - for example, I can only the beginning of the URL. How to fix?

    After that the last version of Firefox all amplified, I used the add-on of NoSquint (60%), which makes web pages now as they did before. However, if the two albums at the top of the screen are of normal size, the lower ones are too big. The bar that contains the URL on the left and a Google search on the right space, for example, to view only the first two letters of a URL (after the / /).

    How can I make these bars look the way they used to? Thank you.

    To adjust the font size for the user interface, you can use the extension of theme font & size changer .

    This solve your problems? Please report to us!

    Thank you.

  • Slider with integer values only?

    I want to create the slider which accepts integer values only.

    For example: 1.0 to 5.0, step: 1.0

    How to do this?

    In a Word, DIY there is no entire cursor in Cascades.

    Wrap the cursor (ongoing) standard floating point in your own class.
    Listen to the signal valueChanged (float) and immediateValueChanged (float).
    Make your own signals when the cursor moves to one discrete value to another.
    Fix the position of the cursor continues to nearest discrete value in the signal valueChanged (float) handler.

    For each continuous cursor position you will need to find the nearest discrete value.

  • "search query: = services the remote procedure call failed and did not run".

    My computer crashed two days ago and I'm finally home, but whenever I try to open a window of any folder I keep refusing. In particular the main computer folder. One of the error messages I got is the following:

    search query: = services the remote procedure call failed and did not run

    Followed by this one:

    The remote procedure call failed and did not execute.

    I opened the Task Manager and tried to access the services from there, but whenever I do, the Task Manager window freezes.

    How can I fix it, my computer is so slow running and does hardly anything and guard with all freezing orders that I try.

    Hello

    This error generally, if the system is infected with Virus and malware or system files are corrupt.

    Please, try the methods below and check if the problem persists.

    SFC scanner.

    You can read the following Microsoft article to repair corrupted using SFC tool files. Use the System File Checker tool to repair missing or corrupted system files

    Reference: http://support.Microsoft.com/kb/929833/en-us

    If the problem persists, try a run Microsoft Safety Scanner.

    http://definitionupdates.Microsoft.com/download/definitionupdates/safetyscanner/amd64/msert.exe

    The Microsoft Security Scanner is a downloadable security tool for free which allows analysis at the application and helps remove viruses, spyware and other malware. It works with your current antivirus software.

    Note: The Microsoft Safety Scanner ends 10 days after being downloaded. To restart a scan with the latest definitions of anti-malware, download and run the Microsoft Safety Scanner again.

    Important: The data files that are infected must be cleaned only by removing the file completely, which means that there is a risk of data loss.

    Do try the suggestions above and let us know the results.

  • Error "Index out of range" on search query

    I have a configuration of search query to clear my listview and insert new results of the query in the listview. The code looks like this:

    {OnDataLoaded}

    _APP. Clearlist

    root. ListView.insertlist (Data)

    }

    {OnQueryChanged}

    Load();

    }

    But unfortunately, whenever I do a query, and as a result appears my query update (triggered from a contextual menu) does not work and gives me the error "Index out of range". Even if the results of the query to fill listview very well and when I tap on a result it shows all data fine as well.

    And FYI the update query does not work when the list is not be searched or filtered so I don't think that there is a problem with my function.

    What I am doing wrong?

    He solved.  The problem is that the update function trying to remove and add the updated item within the filtered datamodel causing problems.  I just got the datamodel to load before performing the functions as described below:

    bool App::updateObject(const QString &id, const QString &name, const QString &description, const QString &datefield, const QString &lat, const QString &lon, const QString &categoryfield, const QString &mapurl, const QString &itempic)
    {
        bool updated = false;
        bool saved = false;
    
    //    if (!validateID(id))
    //        return false;
    
        Location *location = new Location(id, name, description, datefield, lat, lon, categoryfield, mapurl, itempic);
    
        // Find location in the datamodel.
        // Only the id is used by find(). This is because location
        // defines equality (==) as having the same id. (See the definition of "=="
        // in the location class.)
        const QVariantList updateIndexPath = m_dataModel->find(location);
    
        // update the item if found
        if (updateIndexPath.isEmpty()) {
            alert(tr("Object ID not found."));
            updated = false;
        } else {
            load();
            updated = m_dataModel->updateItem(updateIndexPath, location);
        }
    
        // Save the datamodel if we updated something.
        if (updated) {
            m_storage->deleteFromDB(id);
            saved = m_storage->save(m_lastCustomerID, m_dataModel);
            load();
            refreshGroup();
    
        }
    
        return (updated && saved);
    }
    
  • Questions of security and Query By Example

    Hello

    I started to look at security issues in our ADF application.


    Is the implementation of the default Query By Example (QBE) on a secure table of Cross Site Scripting and SQL Injection?

    In other words, a user can enter a value in an input field of QBE, which can be:

    - run a malicious script (CSS)

    Or

    - somehow the underlying change will change the SQL query

    I'm more concerned by the injection of SQL code that QBE supports entry of a user of the web, and makes a corresponding SQL query to the database.


    Are there ways to prevent these?


    Thank you

    I can't find this necessary for qbe. The entry in this field are to save through the use of bind variables.  "<' and="" '="">" are operators valid for cheaper and more, so remove the qbe fields will degrade the use of qbe.

    Timo

  • OIM 11 g: search query for users with a particular resource

    I have a custom resource that has a search on this query to find a list of users. It works very well. I can find the user by username, email or name and first name.

    Existing query:

    Lookup column name: = usr_login
    Column names: usr_key
    Legends of the column: key, username, Email, name and first name
    The width of the columns: 10, 100, 100, 100
    Search query: select usr_key, usr_login, usr_full_name, usr_email usr

    What I want to do is limit the scope of the search query to find only provisioned users with a specific resource. I want to choose users have the MS Exchange resource assigned to them.

    Can someone help me with the creation of the search query that allows you to search for users who have a particular resource put into service? This table contains a list of the resources allocated to a user?

    Thank you.

    use under request

    SELECT USR. USR_KEY, USR. USR_LOGIN, USR. USR_FIRST_NAME, USR. USR_LAST_NAME, OBJ. OBJ_NAME, OST. THE USR, OUEDRAOGO, OST, OBJ OST_STATUS
    Where USR. USR_KEY = OUEDRAOGO. USR_KEY
    AND OUÉDRAOGO. OST_KEY = OST. OST_KEY
    AND OST. OBJ_KEY = OBJ. OBJ_KEY
    AND OST. OST_STATUS IN ('Provisioned', 'Disabled', 'Enabled')
    AND higher (OBJ. OBJ_NAME) = upper ("name of your resource object")

    update status, name of the resource object, and then select the attribute accordingly

    -nayan

  • ORA-01461: can bind to a LONG value only for insert into a LONG column

    Hello

    Oracle XE on RHE dedicated server
    create table cvDetails(
    cd_id number(14) primary key,
    cv_id number(14) constraint education_fk references CvProperties(cv_id),
    nationality varchar2(230),
    objectives varchar2(3900),
    name varchar2(230),
    fatherName varchar2(230),
    motherName varchar2(230),
    dob varchar2(230),
    gender varchar2(230),
    mStatus varchar2(230),
    passportNo varchar2(110),
    email varchar2(230),
    phone varchar2(45),
    mobile varchar2(25),
    address varchar2(2500),
    state varchar2(230),
    zipCode varchar2(230),
    city varchar2(230),
    education clob,
    experience clob,
    skills clob,
    languages varchar2(1400),
    hobbies varchar2(3200),
    achievements varchar2(3900),
    references varchar2(3900)
    );
    
    create sequence cvDetails_seq
    start with 1 increment by 1;
    
    create or replace trigger cvDetails_trig
    before insert on cvDetails
    referencing new as new
    for each row
    begin 
    select cvDetails_seq.nextval into :new.cd_id from dual;
    end;
    /
    Why do I get the error of subject?

    Thank you in anticipation

    >
    in any case, I checked manually according to your instructions and found that this objective column is of character input more than specified.
    >
    Glad you found the problem, but I hope that you learned a lesson that is time consuming.

    It must be remembered that we have no access to your environment. If we do not know which servers, clients, tables and users that you use.
    It may seem simple to you but doesn't realize that you provide us with two slightly different versions of the cvDetails table.

    The original post had this
    >
    objectives varchar2 (3900).
    >
    But when you have provided your 'cvDetails desc' journal text has
    >
    OBJECTIVES VARCHAR2 (3950)
    >
    It is the same table that you started with how the column suddenly grow 50 bytes?
    This means that you did from different parts of the present in the two schemas or on two servers or you change the table between the two.

    You can't address properly when you do this. By chance it is the column that you said is now the problem.
    In SQL, the maximum length of a VARCHAR2 is 4000 bytes; no characters but bytes. Nothing more than 4000 bytes would probably be a LONG in the generic sense.

    If your error
    >
    Re: ORA-01461: can bind to a LONG value only for insert into a LONG column
    >
    means that you try to 'bind a LONG value' to a column VARCHAR2 and you can't you can 'bind a LONG value only for insert in a LONG column.

    In the proper context, the error makes sense.

    You probably have a problem with

     ps.setString(2,  objectives);
    

    because the 'objectives' has a length of more than 4000 bytes.

    Remember this answer from you?
    >
    I have read and found that there may be a problem with the driver JDBC or Characterset. Am I wrong?
    >
    The 'Hello' ASCII string is five characters and five bytes because the ASCII code is a set of characters in a single byte. The same string internally in Java is five characters but ten bytes because Java uses UTF16.

    So, if the character set of the data itself is double-byte character set then anything more than 2000 characters (4000 bytes) is a "LONG". And if your column is defined as VARCHAR2 (3950), which means bytes a doublel-byte character set which are characters of 1975.

    Then you said in a response later
    >
    I checked by the SNA Server and oracle that are both of the same but new thing I found is that oracle does not allow more than one clob column in a table. Is this true?
    >
    Somehow a hypothesis has crept it that the problem was not a driver JDBC or Charaterset, but because you can not have more than one clob column in a table.

    You could have easily tested for yourself by doing what P. Forstmann - tried to create a table and see.

    Then you completely ignored my advice
    >
    I suggest to you isolate the columns actually causing the problem.
    Change your code to insert only a few columns. When it works, add more than a few columns.
    This will then tell you which column or the columns are at the origin of the problem.
    Display the results once you determine a column that causes the error.
    >
    When you have finally made the simplest things, you have found what was causing the problem almost immediately.

    Many times you don't need 'experts' - you must use a rigorous, methodical, process step by step.

    ALWAYS, ALWAYS, ALWAYS reduce the simplest possible code example that illustrates the problem.
    If you had followed this a rule would have probably found you the problem and makes you look like the 'expert '.

    There are no shortcuts.

  • DataPump the QUERY parameter with string values? -SOLVED

    All,

    I'm trying to specify a query to the datapump API parameter but can't seem to get my correct single/double quotes so that it can work. I can successfully use the QUERY parameter with something like QUERY = table: '"number_column = 6" ' but NOT with something like QUERY = table:'"string_column ="value"" "

    I tried different versions of the single/double quotes, but all fails with slightly different errors. Someone at - it an example where a string value is used with success?

    Thanks in advance. Oracle 10.2.0.3.0 - AIX 5.3

    So after reading some other reviews on another thread - I tried this and it worked:

    QUERY = table:------"where string_column = 'value\' \' \

    Looks like you have escape all single/double quotation marks for this parameter

    Published by: potter_geek on August 31, 2009 10:47

    Hello

    Use the parameter file or if you run expdp command-line use escape character '-' (backslash) in this case.

    Concerning
    Anurag Tibrewal.

  • Paste values only Excel

    Hello

    I'm trying to paste some values from an excellent worksheet to another. I have no problem to paste the cells in the State, the problem is, the cells that I copy contain formulas in them to calcute some information for me. I would like to paste values only. In excel you would do this by copy--> paste special--> values. I made a macro and tried to fallow it Word by Word. I got stuck when the paste special options surfaced. I have attached the image I hope it helps. If it is simply ask a VI and I will gladly make a sample vi.

    In fact, you can just right-click on the element of 'Paste' and select Create-> constant. This should create a constant enum where you can select the appropriate value.

  • java.lang.NullPointerException when you click on the search query

    java.lang.NullPointerException when you click on the search query:

    There is nothing my project involved code...

    at oracle.adf.model.binding.DCControlBinding.reportException(DCControlBinding.java:201)
    at oracle.jbo.uicli.binding.JUCtrlValueBinding.findAttributeDef(JUCtrlValueBinding.java:632)
    at oracle.jbo.uicli.binding.JUCtrlValueBinding.findAttributeDef(JUCtrlValueBinding.java:597)
    at oracle.jbo.uicli.binding.JUCtrlValueBinding.getAttribute(JUCtrlValueBinding.java:1341)
    at oracle.adfinternal.view.faces.model.binding.FacesCtrlSearchBinding$AdfAttributeDescriptor.isRequired(FacesCtrlSearchBinding.java:3018)
    at oracle.adfinternal.view.faces.renderkit.rich.query.QueryBehavior.shouldShowInstructionText(QueryBehavior.java:66)
    at oracle.adfinternal.view.faces.renderkit.rich.query.QueryBehavior.refreshInfoFacet(QueryBehavior.java:37)
    at oracle.adfinternal.view.faces.renderkit.rich.QueryRenderer.renderContentRow(QueryRenderer.java:718)
    at oracle.adfinternal.view.faces.renderkit.rich.PanelHeaderRenderer.encodeAll(PanelHeaderRenderer.java:231)
    at
    
    

    Cvele_new_account, good point.

    Maybe you can try to remove the af: query to the page, and then drop it again.

  • ORA - 01461:can bind a LONG value only for insert in a LONG column. After upgrade to 11g

    After update, oracle 11g, we get the system error when you try to insert the text string in the NCLOB type column.

    ORA - 01461:can bind a LONG value only for insert in a LONG column.

    This has not happened on an earlier version of Oracle.

    I did some testing and found that, if a string more then 2000 we get this error.

    How to solve this problem?

    Thank you

    I found a solution. I had to update ODP.NET to 2.112.1.0 version.

Maybe you are looking for