MS ACCESS, NULL, and '%'

I am using a prepared statement to query my access database which contains personal data first name, last name, address, city, state, etc.... I allow the user to search the database by any of these fields (or any combination of them) by making the default values for any empty fields '%'. Here's my select statement.
stmt =conn.prepareStatement("SELECT * FROM Data1 WHERE first_name LIKE ? AND last_name LIKE ? AND city LIKE ? ....");
stmt.setString(1, firstNameField.getText()+"%");
stmt.setString(2, lastNameField.getText()+"%");
stmt.setString(3, cityField.getText()+"%");
This worked but didn't return a record if ANY of their values are NULL. So I changed my select statement to allow for NULL values.
stmt =conn.prepareStatement("SELECT * FROM Data1 WHERE (first_name LIKE ? OR first_name IS NULL) AND (last_name LIKE ? OR last_name IS NULL) AND (city LIKE ? OR city IS NULL) ....");
stmt.setString(1, firstNameField.getText()+"%");
stmt.setString(2, lastNameField.getText()+"%");
stmt.setString(3, cityField.getText()+"%");
This fixed that problem, but now it ALWAYS returns the records with NULL fields. I want it to only match NULL fields if the coressponding JTextField is left blank. Can anyone tell me a good way to do this?

How can I create it dynamically and still keep the
speed of a prepared statement??Unless you are doing block inserts in a loop you are probably not going to see any speed improvement anyways.
But as I said you can simply create all the combinations and then use an array to keep track of them.

Similar Messages

  • Null and no data in field value

    I transferring sql from MS Access to Oracle 9i.
    In Access I have this
    select * from tableOne where firstname <> ''
    and firstname & '' = ''The firstname field can be edited where it could have data and the data could be deleted so I am trying to select records where firstname is not null and it has no data in it.

    I transferring sql from MS Access to Oracle 9i.
    In Access I have this
    select * from tableOne where firstname <> ''
    and firstname & '' = ''
    select * from tableOne where firstname IS NULL;
    - or -
    select * from tableOne where firstname IS NOT NULL;
    as appropriate.
    In Oracle there is no difference betwen being NULL and having data of length '0'

  • Nulls and Empty Strings

    I have an ODBC application whose backend has been changed from Access to Oracle. There is one particular query that is causing problems. The query contains a where clause with something like "field = ''" in it. This query is intended to pick up records where field is null. If the query was modified to "field is null," it would work. However, I cannot change the application.
    Is there any way to configure the ODBC driver or something so that this query would work properly? I've tried defaulting the field to '', but Oracle is still treating it as null.
    (What is really frustrating is that the application NEVER populates this field!)

    Actually, Oracle is very consistent in that it requires you to use ternary logic when dealing with null values. NULL is never equal to a value, NULL is never not equal to a value.
    select * from someTable where column <> 'value'
    will show you only those rows in someTable where column is non-NULL and where its value is not 'value'
    select count(*) from someTable !=
    select count(*) from someTable where column <> 'value' +
    select count(*) from someTable where column = 'value'
    select count(*) from someTable =
    select count(*) from someTable where column <> 'value' +
    select count(*) from someTable where column = 'value' +
    select count(*) from someTable where column IS NULL
    There are plenty of discussions in Oracle texts and in Oracle newsgroups that go into much greater detail about the how's & why's of this.
    Justin

  • Can't Access MovieClips and Functions in Loaded SWF

    Hi everybody,
    I'm trying to simply access anything inside this loaded SWF and all I get is 'null'.
    I have code in the parent SWF that needs to tell the child SWF movieclip what to do but nothing works. This was a piee of cake in AS2 and I can't seem to get anything to crossover in AS3.
    Here's my code:
    import com.greensock.TweenMax;
    import flash.display.MovieClip;
    var myLoader:Loader = new Loader();
    var url:URLRequest = new URLRequest("SWCS_S3_500x250_exp_panel_2.swf"); // in this case both SWFs are in the same folder
    myLoader.load(url);  // load the SWF file
    panel2.addChild(myLoader);   // add that instance to the display list, adding it to the Stage at 0,0
    panel2 = myLoader.content as MovieClip;
    photo_about.alpha = 0;
    photo_downloads.alpha = 0;
    //panel2.content_about.alpha = 0;
    //panel2.content_downloads.alpha = 0;
    function closeSection():void
              panel2.controlsMC.forcePause();
              TweenMax.to(photo_about, .5, {alpha:0});
              TweenMax.to(photo_downloads, .5, {alpha:0});
              TweenMax.to(photo_home, .5, {alpha:0});
              TweenMax.to(panel2.content_about, .5, {alpha:0});
              TweenMax.to(panel2.content_downloads, .5, {alpha:0});
              TweenMax.to(panel2.controlsMC, .5, {autoAlpha:0});
              TweenMax.to(panel2.content_home, .5, {alpha:0});
    panel2 traces null and all the clips loaded within pull up undefined property errors.
    Can somebody please tell me what I'm doing wrong? I'd be stoked to know what I'm missing and feel like this should be a piece of cake.
    Thanks for any help!

    You are not adding the content to the stage at 0,0, you are adding it to panel2 at 0,0.  THen you take panel2 and assign it to be something that likely doesn't exist by the time you assign it.  You need to wait until the loader completes loading before you attempt to do anything with its content, otherwise it has no content (null).  Similarly, you cannot control anything in the loaded swf until it has finished loading.  So assign an event listener to the contentLoaderInfo property of the Loader to determine when loading is complete, and have the event handler function deal with starting the interaction with it.
    var myLoader:Loader = new Loader();
    var url:URLRequest = new URLRequest("SWCS_S3_500x250_exp_panel_2.swf");
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, processLoadedSWF);
    myLoader.load(url);
    function processLoadedSWF(evt:Event):void {
        // deal with the loaded swf here
        // but you don't want to be assigning it to the panel2 object that contains the loader
    As far as controlling anything inside the swf you load, is it an AS1/2 or an AS3 swf?

  • FRM-92102 error when accessing Forms and Peoplesoft simultaneously

    We are receiving an FRM-92102 error when we access Peoplesoft and then our web forms application simultaneously.
    Here is the error message:
    Java Plug-in 1.6.0_11
    Using JRE version 1.6.0_11 Java HotSpot(TM) Client VM
    User home directory = C:\Documents and Settings\SICARDT
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    q: hide console
    r: reload policy configuration
    s: dump system and deployment properties
    t: dump thread list
    v: dump thread stack
    x: clear classloader cache
    0-5: set trace level to <n>
    RegisterWebUtil - Loading WebUtil Version 10.1.2.3
    Loaded image: http://gdocdev.ic.gc.ca/gdoc/images/gdoc.gif
    Loaded image: http://gdocdev.ic.gc.ca/gdoc/images/gdoc.gif
    proxyHost=null
    proxyPort=0
    connectMode=HTTP, native.
    Reconnecting (try 1 of 5)...
    Reconnecting (try 2 of 5)...
    Reconnecting (try 3 of 5)...
    Reconnecting (try 4 of 5)...
    Reconnecting (try 5 of 5)...
    oracle.forms.net.ConnectionException: 500
         at oracle.forms.net.ConnectionException.createConnectionException(Unknown Source)
         at oracle.forms.net.HTTPNStream.getResponse(Unknown Source)
         at oracle.forms.net.HTTPNStream.doFlush(Unknown Source)
         at oracle.forms.net.HTTPNStream.flush(Unknown Source)
         at java.io.DataOutputStream.flush(Unknown Source)
         at oracle.forms.net.HTTPConnection.connect(Unknown Source)
         at oracle.forms.engine.FormsDispatcher.initConnection(Unknown Source)
         at oracle.forms.engine.FormsDispatcher.init(Unknown Source)
         at oracle.forms.engine.Runform.initConnection(Unknown Source)
         at oracle.forms.engine.Runform.startRunform(Unknown Source)
         at oracle.forms.engine.Main.createRunform(Unknown Source)
         at oracle.forms.engine.Main.start(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)

    Can you provide more information? For example:
    1. Does one or both apps use SSO?
    2. Does one or both apps use SSL?
    3. Are both apps being called from the same browser session? Remember that just because you may have two browser windows open does NOT mean they are running as separate sessions. If you started the second browser using java script, CTRL+N, or a URL shortcut, then they are likely same session.
    This error suggest that there is a critical tcp/ip failure:
    oracle.forms.net.ConnectionException: 500+
    If the browser to run Forms and PS is the same session, there is likely a session ID conflict. Try opening one browser using the shortcut created for the browser (usually found on the desktop). Do not use a shortcut which contains an embedded URL. Open one of the apps. Then, do the same again to start the second app. If possible, run one app from IE and the other from Firefox (or other browser).

  • Security Sandbox violation bitmapData.draw() cant access null

    very strange.  I am testing with two different HD streams.  One an akamai stream and another one of our clients not on akamai and using an F4M manifest file.  I have tried allowing the domain and they have a crossdomain.xml file on their side but i still get this error.  
    SecurityError: Error #2123: Security sandbox violation: BitmapData.draw: http://web.mobilerider.com/flash/osmflive/OSMF_Live.swf?mediaID=190&vendorID=513&extras=vs :1,skin:osmf_live,muteOn:0,autoplay:1,live:1,showArchive:1,&serviceID=2&jsID=1316213568052 cannot access null. No policy files granted access.
    any help would be very appreciated, thanks

    Hello!
    This seems to be relevant:
    http://forums.adobe.com/message/3759490#3759490

  • Cannot access Null obj ref

    Hi
    I have a navigation list on my view...and ONSELECT of a particular item in the list i have written the below code
    DATA lo_componentcontroller TYPE REF TO ig_componentcontroller.
    DATA ls_navi_list TYPE wd_this->element_NAVI_LIST.
    data CONTEXT_ELEMENT TYPE REF TO IF_WD_CONTEXT_ELEMENT.
    Get key information for selected navigation list entry
    break-point.
    context_element->get_static_attributes(
    IMPORTING
    static_attributes = ls_navi_list ).
    how ever i am getting the error "cannot access null obj ref " at
    context_element->get_static_attributes(
    IMPORTING
    static_attributes = ls_navi_list ).

    Oooohhh! Now I got the problem!
    The problem is that inside the function, you have an if clause, that when the SWF loads an amount of bytes, you send it to the frame four. The problem occurs because even you sending it to fame four, it is still listening to the PROGRESS_EVENT, when this events is dispatched the method is called again, trying to set the label to the textfield that does not exists anymore.
    To resolve it, just add a removeListener before send it to frame 4.
    function PL_LOADING(event:ProgressEvent):void {
         if (event.bytesLoaded>=3704635) {
              this.loaderInfo.removeEventListener( ProgressEvent.PROGRESS, PL_LOADING );
                   this.gotoAndStop(4);
    if (this.loaderInfo.bytesLoaded >= this.loaderInfo.bytesTotal) {
          this.loaderInfo.removeEventListener( ProgressEvent.PROGRESS, PL_LOADING );
              this.gotoAndStop(4);
    This will fix the problem.
    Regards,
    CaioToOn!

  • OCI, Nulls and bind mismatch

    I am having some issues with a third party application that used OCI to access the database, we have a problem statement that generates hundreds of child cursors for a specific statement. Investigating v$sql_shared_cursor show the reason for this a bind mismatches, on tracing the binds this seems to happen where nulls are bound into the number fields (the statement updates 43 values in one row of a table). This is really killing the database performance, is anyone aware of an issue with binding nulls in OCI similar to this http://www.usn-it.de/index.php/2010/08/04/oracle112-mutex-s-too-many-child-cursors/ seen in the jdbc drivers.
    As its a third party application I can;t get hold of the code and the vendors support have identified it as a slow database issues rather than actually look at the code to figure out whats going on the versions of oracle involved are
    Database: 11.2.0.2 + patchset update 2 + one off patches 12431716,12423122,11664046
    Client version: OCI (whichever comes with instant client 11.2.0.1)
    Chris

    Hi Chris,
    Inside API calls in the application is different for null and not-null. Refer to my post : OCIBindByPos() 8th parameter and its impact on performance for more.
    However, there is no indication in OCI documentation or any other doc about the behavior of child cursors with null concept although the null support is available from Oracle 8.
    We are running some tests and will update the forum from findings.

  • Using NULL and NOT NULL in prompted filters

    Dear all,
    While trying to grap the concept of prompted filters in sap bo web intelligence, I had a question whether why we cannot use NULL and NOT NULL while creating a prompted filters in our report.

    HI,
    'Is Null' and 'Not Null' are the predefined functions in webi which only eliminate the null values or considering only null values.
    'Is Null' and 'Not Null' are itself predefined functions that why you are not getting  prompts.
    Null values are standard across the databases so this is defined  as a function in webi to specific eliminate the null values.
    If something is not standard then there is option in the webi to use different operator with static values or with prompts.
    More more information on Null see the Null wiki page.
    Null (SQL) - Wikipedia, the free encyclopedia
    Amit

  • Not null and enable or disable  column in tabular form

    Hi,
    Using apex version 4.1 and working on tabular form.
    ACT_COA_SEGMENT_MAS is Master table
    and
    ACT_SEGMENT_VALUES_MAS is detail table
    I have entered 8 rows in master table and PARENT_SEGMENT_ID is column in master table which is null able. If i specified PARENT_SEGMENT_ID with value in master table then in detail table there is column PARENT_ID that should not be null and enable.
    How i can enable or disable column when in master table PARENT_SEGMENT_ID column is null then in detail table PARENT_ID column should disable and vice versa.
    I have created tabular form on Detail table. before insert into the tabular form Check in master table in first entry if PARENT_SEGMENT_ID is not null in first row of master table then in tabular form PARENT_ID should enable and not null able in corresponding to this first row id's lines in tabular form.
    Same should check for second row in master table if PARENT_SEGMENT_ID is not null then entered rows with PARENT_ID into tabular form corresponding to 2nd id in master table should not nullable and column should enable in tabular form.
    Thanks & Regards
    Vedant
    Edited by: Vedant on Jan 9, 2013 9:12 PM

    Vedant,
    You need to create you own manual tabular form and not use the wizard.
    Using APEX_ITEM api you should be build you own form and you will be able to control how you wan to display the rows. (See Link [Apex Item Help|http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35127/apex_item.htm#CACEEEJE] )
    select case when PRIMARY_TABLE_COLUMN is null then APEX_ITEM.DISPLAY_AND_SAVE(3 , DETAIL_COLUMN ) else APEX_ITEM.TEXT(2,detail_column) end "ALIAS" from detail table
    Hope that help.
    Vivek

  • Connection ==null and Connection is closed, difference

    Hi experts,
    I wonder what are the differences between "Connection==null" and "Connection is closed"?
    I closed a connection on one JSP page after a bean has retrieved data. Then, on the same page I call another bean to connect to the database. Because the Connection object has been created earlier, therefore Connection is not NULL, but it is closed. So, the second bean has to initiate another connection(if I knew how to test the "closed" status)
    Is it true that if the Connection is closed, then it should become null?
    I think I must have make quite a few mistakes in above statement:). Please help. Thanks a lot.

    connection.isClosed() will tell you if the connection object is closed or not. If it is closed, then the connection object can be dropped because you will not be able to create any new statements from that connection object. Just recreate another connection to use when this occurs.

  • Is null and regular value in where ($variable)

    is there any polibility to create select depend on value in where ?
    select count(x) where y = $variablebut if variable is NULLit doesn't work cause must be IS NULL or IS NOT
    select count(x) where y is $variableIs there any posibility to make it working with null and regular variable?

    try:
    select count(x) from <yourtable> where nvl(y,<not_possible_value>) = nvl($variable,<not_possible_value>);where <not_possible_value> is a value that is not possible for column y.
    E.g. if y always is a positive number you could use the value -1.

  • Avoiding null and duplicate values using model clause

    Hi,
    I am trying to use model clause to get comma seperated list of data : following is the scenario:
    testuser>select * from test1;
    ID VALUE
    1 Value1
    2 Value2
    3 Value3
    4 Value4
    5 Value4
    6
    7 value5
    8
    8 rows selected.
    the query I have is:
    testuser>with src as (
    2 select distinct id,value
    3 from test1
    4 ),
    5 t as (
    6 select distinct substr(value,2) value
    7 from src
    8 model
    9 ignore nav
    10 dimension by (id)
    11 measures (cast(value as varchar2(100)) value)
    12 rules
    13 (
    14 value[any] order by id =
    15 value[cv()-1] || ',' || value[cv()]
    16 )
    17 )
    18 select max(value) oneline
    19 from t;
    ONELINE
    Value1,Value2,Value3,Value4,Value4,,value5,
    what I find is that this query has duplicate value and null (',,') coming in as data has null and duplicate value. Is there a way i can avoid the null and the duplicate values in the query output?
    thanks,
    Edited by: orausern on Feb 19, 2010 5:05 AM

    Hi,
    Try this code.
    with
    t as ( select substr(value,2)value,ind
            from test1
            model
            ignore nav
            dimension by (id)
            measures (cast(value as varchar2(100)) value, 0 ind)
            rules
            ( ind[any]=  instr(value[cv()-1],value[cv()]),
            value[any] order by id = value[cv()-1] || CASE WHEN value[cv()] IS NOT NULL
                                               and ind[cv()]=0     THEN ',' || value[cv()] END      
    select max(value) oneline
    from t;
    SQL> select * from test1;
            ID VALUE
             1 Value1
             2 Value2
             3 Value3
             4 Value4
             5 Value4
             6
             7 value5
             8
    8 ligne(s) sélectionnée(s).
    SQL> with
      2   t as ( select substr(value,2)value,ind
      3          from test1
      4          model
      5          ignore nav
      6          dimension by (id)
      7          measures (cast(value as varchar2(100)) value, 0 ind)
      8          rules
      9          ( ind[any]=  instr(value[cv()-1],value[cv()]),
    10          value[any] order by id = value[cv()-1] || CASE WHEN value[cv()] IS NOT NULL
    11                                             and ind[cv()]=0     THEN ',' || value[cv()] END 
    12          )
    13        )
    14   select max(value) oneline
    15   from t;
    ONELINE
    Value1,Value2,Value3,Value4,value5
    SQL>

  • Replacing NULL and EmptyString('') with "Unknown" in SSRS parameter dropdown

    All,
    What I want to do is, in the SSRS parameter drop down, instead of showing NULL and Blank values(), i want to categorize them as "Unknown", so, if the user selects "Unknown" from the SSRS drop down parameter, he should be able to see all
    the records that have NULL values or empty strings in that particular column in the result set.
    Can you tell me, how should I handle it in my main stored proc as well as in the dataset?
    Right now, i have something like this:
    Where
    (t1.name in (select value from dbo.Split(@TName,',')) OR @TName IN ('All'))
    -- Where t1.Name has empty strings and NULL values. Both of these values should be categorized under "Unknown"
    -- How would the dataset query look like? Right now I have this query for populating the drop down for that parameter:
    Select All
    UNION
    Select Distinct Name
    Order BY 1

    Hello,
    Please refer to the following stored procedure:
    SELECT
    CASE WHEN TName IS NULL OR TName = ''
    THEN 'Unknown' ELSE TName END AS TName
    From DemoTable
    Then, use following query code to get the parameter values:
    SELECT Distinct
    CASE WHEN TName IS NULL OR TName = '' THEN 'Unknown'
    ELSE TName END AS TName
    FROM DemoTable
    Regards,
    Alisa Tang
    Alisa Tang
    TechNet Community Support

  • NULL and Space value in ABAP

    Hi All,
           I like to know, is it NULL and Space value is same in ABAP, if it is not how to check null value.
    Thank you.
    Senthil

    everything is correct though some answers are not correct.
    A Database NULL value represents a field that has never been stored to database - this saving space, potentially.
    Usually all SAP tables are stored with all fields, empty fields are stored with their initial value.
    But: If a new table append is created and the newly-added fields do not have the 'initial value' marked in table definition, Oracle will just set NULL values for them.
    as mentioned: There is no NULL value to be stored in an ABAP field. The IS NULL comparison is valid only for WHERE clause in SELECT statement. WHERE field = space is different from WHERE field IS NULL. That's why you should check for both specially for appended table fields.
    If a record is selected (fulfilling another WHERE condition) into an internal table or work area, NULL values are convertted to their initial values anyway.
    Hope that sheds some light on the subject!
    regards,
    Clemens

Maybe you are looking for

  • Logic Pro 7.2 and Tascam FW-1884 Not Working

    I recently upgraded to Logic Pro 7.2 and I'm using a Tascam FW-1884 as my audio interface / Control Surface. Everything was working fine in 7.1.1, but now it doesn't work correctly. When I press buttons and faders on the Tascam I see MIDI information

  • Received emails are displayed and printed with a lot of garbage info after the To: line

    For example: X-Account-Key X-uidl X-Mozilla Status ect

  • PS CS5 crashing in 64bit mode

    Occasionally - without any obvious reasons, I experience that PhotoShop crashes after a few seconds when I start it in 64bit mode. No problems in 32 bit mode though. Is there a solution to this? (And do forgive the norwegian language in the crashrepo

  • How to use search fragments in WCM

    Hi, I am trying to use sample fragments named search box plain and search result plain while creating my site in hcsp. I am unable to integrate these two fragments. whenever i pass a query, i get the message No documents match your search criteria.

  • The program is automatically launching into the debug mode.

    Hi, I have written a small servlet program. When I try to run the program it automatically launches itself into the debug mode. I have tried all things but I am not able to prevent this from happening. Can anyone help me with this. Regards, Prashant