Null and Empty Values

Hi All,
Is there a parameter which allows me to translate automatically the instruction
select * from table_a where col_a = ''
in
select * from table_a where col_a is null
Thanks

Not in Oracle, no. col_a = NULL and col_a IS NULL are logically distinct clauses. If you are dealing with NULL's, you absolutely must use three-valued logic in your statements.
Depending on what you are doing, you may be able to throw an NVL on col_a to ensure a non-NULL value is returned.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • 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

  • Null and empty string not being the same in object?

    Hello,
    I know that null and empty string are interpreted the same in oracle.
    However I discovered the strange behaviour concerning user defined objects:
    create or replace
    TYPE object AS OBJECT (
    value VARCHAR2(2000)
    declare
    xml xmltype;
    obj object;
    begin
    obj := object('abcd');
    xml := xmltype(obj);
    dbms_output.put_line(xml.getStringVal());
    obj.value := '';
    xml := xmltype(obj);
    dbms_output.put_line(xml.getStringVal());
    obj.value := null;
    xml := xmltype(obj);
    dbms_output.put_line(xml.getStringVal());
    end;
    When creating xml from object, all not-null fields are transformed into xml tag.
    I supposed that obj.value being either '' or null will lead to the same result.
    However this is output from Oracle 9i:
    <OBJECT_ID><VALUE>abcd</VALUE></OBJECT_ID>
    <OBJECT_ID><VALUE></VALUE></OBJECT_ID>
    <OBJECT_ID/>
    Oracle 10g behaves as expected:
    <OBJECT><VALUE>abcd</VALUE></OBJECT>
    <OBJECT/>
    <OBJECT/>
    However Oracle 9i behaviour leads me to the conclusion that oracle
    must somehow distinguish between empty string and null in user defined objects...
    Can someone clarify this behaviour?
    Thus is it possible to test if object's field is empty or null?

    However Oracle 9i behaviour leads me to the conclusion that oracle
    must somehow distinguish between empty string and null in user defined objects...
    Can someone clarify this behaviour?
    Thus is it possible to test if object's field is empty or null?A lot of "fixes" were done, relating to XML in 10g and the XML functionality of 9i was known to be buggy.
    I think you can safely assume that null and empty strings are treated the same by Oracle regardless. If you're using anything less than 10g, it's not supported any more anyway, so upgrade. Don't rely on any assumptions that may appear due to bugs.

  • System.Exception: null or empty values

    Have designed a 4 part form Using DW MX, ASP.NET C# and MySQL
    and currently getting the below error when moving from one page to
    the next.
    The web.config file is on the server, there are no null or
    empty values, and the key tags match.
    I am new to applicaiton development in DW and am now stuck -
    any suggestions?
    System.Exception: This page has a MM:DataSet, MM:Insert,
    MM:Update or MM:Delete tag with a null or empty value for the
    ConnectionString and DatabaseType attributes.
    Often, such values come from application settings in the
    web.config file. That file might be missing from the server
    executing this page. Or, it might be missing the particular add key
    tags for the database connection this page uses. If you are using
    Dreamweaver, look for the web.config file in the local root folder
    of your Dreamweaver site. Once you find this file, you can either:
    Put this file onto the server that is executing this page.
    Copy the add key tags from the web.config in the local root
    folder of your Dreamweaver site and paste them into the web.config
    file in the server that is executing this page.
    at DreamweaverCtrls.DataSet.DoInit()
    Text

    http://java.sun.com/docs/books/tutorial/uiswing/components/spinner.html#model
    Might be a good start.

  • How to see a null or empty value in JFormattedTextField

    Hello, I am having a problem. I'm trying to use a JFormattedTextField, and I keep getting errors.
    I know what is causing the error, but I don't know how to fix it.
    Here is my code:
    String cf = countFTX.getText();
    if(cf.equals(" ")) {
      i = Integer.valueOf(countJTX.getText());
    }else{ i = Integer.valueOf(countFTX.getText()); }what happens is I get an error when it goes to change it into an int. Because it see's it as being (" ") and not (" ") or even ("") so it doesn't fit into my if statement. And returns it being false, then tries to turn it into an int, and blows up there.
    Now how can I fix my if statement to be able to see if nothing was entered, and if so then use the countJTX and not the countFTX?
    countJTX is a regular JTextField, and countFTX is a JFormattedTextField.
    the JTX is filled automaticaly with an int, and if there needs to be a change, the user puts it into the FTX. (so you understand the logic behind it)
    any ideas? or should i just revert to not using the FTX?

    you need to know the differenct between NULL and "" (empty) of a string. Also both of these values cann't converted to in integer so you can not call Integer.valueOf(cf). I don't understand why you need to do that. Instead:
        String cf = countFTX.getText();
        if(cf == null || cf.length() == 0)) {
            i = ?; //something you want i to be when cf is null or empty but not call Integer.valueOf(countJTX.getText());
        }else{
            i = Integer.valueOf(cf);
        }Also, you may need to add try/catch exceptions.

  • How to define null or empty value in BAPI function modules?

    Hi,
    I have problem with BAPI functions, where some parameters are mandatory.
    For example: when I try to use HR BAPI's(BAPI_PERSDATA_CHANGE, etc.) I have to insert parameters like SUBTYPE,OBJECTID,LOCKINDICATOR. The PA0002 table that is used from this BAPI doesn't have SUBTYPE, OBJECTID, LOCKINDICATOR, for any of the records that I would like to select.
    So what I tried, was to put a ' ', to indicate that is empty. It returned an error message saying "Make an entry in all required fields". Next tried to put in some values for these fields -- and it returned an error message saying "No data selected from 0002 for this period".
    I also tried to run BAPI_FAMILY_CHANGE that uses data from table PA0021. Here I found some records with  SUBTYPE, OBJECTID fields that were not empty, but LOCKINDICATOR was still missing. So I tried to put LOCINDICATOR value directly in to database (with MS SQL Enterprise Manager).  After that I was able to use BAPI_FAMILY_CHANGE.
    I think that manually inserting data in database is not normal procedure.
    Is there something that I have missed out?
    I mean -- how can I get this to work without inserting data directly in database?
    How can I define null or empty value in BAPI function modules?
    Thank you in advance.
    Best regards,
    Mihail

    Defining an empty value for a parm in a table is easy.
    First get the function's definition from the SAP system
    Second only populate the fields for which you have a value to set
    Third execute the function.
    The JCO takes care of the rest.
    Enjoy

  • 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>

  • Difference in Null and Empty String

    Hi,
    I have been wondering about the difference between Null and Empty String in Java. So I wrote a small program like this:
    public class CompareEmptyAndNullString {
         public static void main(String args[]) {
              String sNull = null;
              String sEmpty = "";
              try {
                   if (sNull.equalsIgnoreCase(sEmpty)) {
                        System.out.println("Null and Empty Strings are Equal");
                   } else {
                        System.out.println("Null and Empty Strings are Equal");
              } catch (Exception e) {
                   e.printStackTrace();
    This program throws Exception: java.lang.NullPointerException
         at practice.programs.CompareEmptyAndNullString.main(CompareEmptyAndNullString.java:10)
    Now if I change the IF Clause to if (sEmpty.equalsIgnoreCase(sNull)) then the Program outputs this: Null and Empty Strings are Equal
    Can anyone explain why this would happen ?
    Thanks in Advance !!

    JavaProwler wrote:
    Saish,
    Whether you do any of the following code, the JUnit Test always passes: I mean he NOT Sign doesnt make a difference ...
    assert (! "".equals(null));
    assert ("".equals(null));
    You probably have assertions turned off. Note the the assert keyword has nothing to do with JUnit tests.
    I think that older versions of JUnit, before assert was a language keyword (which started in 1.4 or 1.5), had a method called assert. Thus, if you have old-style JUnit tests, they might still compile, but the behavior is completely different from what it was in JUnit, and has nothing to do with JUnit at all.
    If you turn assertions on (-ea flag in the JVM command line, I think), the second one will throw AssertionError.

  • Check for null and empty - Arraylist

    Hello all,
    Can anyone tell me the best procedure to check for null and empty for an arraylist in a jsp using JSTL. I'm trying something like this;
    <c:if test="${!empty sampleList}">
    </c:if>
    Help is greatly appreciated.
    Thanks,
    Greeshma...

    A null check might not be you best option.  If your requirement is you must have both the date and time component supplied in order to populate EventDate, then I would use a Script Functoid that takes data and time as parameters.
    In the C# method, first check if either is an empty string, if so return an empty string.
    If not, TryParse the data, if successful, return a valid data string for EventDate.  If not, error or return empty string, whichever satsifies the requirement.

  • From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    Hi,
    Use NVL or COALESCE:
    NVL (col_a, col_b)
    Returns col_a if col_a is not NULL; otherwise, it returns col_b.
    Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
    For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • VARCHAR2:: How to differnciate between NULL and empty string '' ?

    Hello to all,
    I'm looking for a possibility to differnciate between NULL and empty string '' in column of type VARCHAR2.
    I have an application relying on that there is a difference between NULL and ''.
    Is it possible to configure ORACLE in some way ?
    Thanx in advance,
    Thomas

    try check if a varchar variable has an empty string
    by checking its lengthAnd that would accomplish what? But see for yourself:
    DECLARE
      v_test VARCHAR2(10);
    BEGIN
      v_test := '';
      DBMS_OUTPUT.put_line(LENGTH(v_test));
      v_test := NULL;
      DBMS_OUTPUT.put_line(LENGTH(v_test));
    END; C.

  • Union two tables with diffrent count of fields with null and float value

    Hello,
    i want to union two tables, first one with 3 fields and second one with 4 fields (diffrent count of fields).
    I can add null value at end of first select but it does not work with float values in second table. Value form second table is convert to integer.
    For example:
    select null v1 from sessions
    union
    select 0.05 v1 from sessions
    result is set of null and 0 value.
    As workaround i can type:
    select null+0.0 v1 from sessions
    union
    select 0.05 v1 from sessions
    or simple change select's order.
    Is any better/proper way to do this? Can I somehow set float field type in first select?
    Best regards,
    Lukasz.
    WIN XP, MAXDB 7.6.03

    Hi Lukasz,
    in a UNION statement the first statement defines the structure (number, names and types of fields) of the resultset.
    Therefore you have to define a FLOAT field in the first SELECT statement in order to avoid conversion to VARCHAR.
    Be aware that NULL and 0.0 are not the same thus NULL+0.0 does not equal NULL.
    In fact NULL cannot equal to any number or character value at all.
    BTW: you may want to use UNION ALL to avoid the search and removal of duplicates - looks like your datasets won't contain duplicates anyhow...
    Regards,
    Lars

  • Hiding Entire Row having Null and default valu in SSRS Using Expression

    Hi,
    In my reports having number of rows and three columns.The first columns  value will be different for each and every row and it will be  hard corded to the text box.  My question is how to hide the particular row second and third column suppose
    to be null or empty data and each and every row had Hide is true.Please provide me the solution if anybody known.
    Regards,
    HariKan
    HariKan

    Hi Qiuyun Yn,
    Thanks for your reply.
     If i use Not Null in my query in where
    condition  then i have to add 30 fields in my where condition,  and i guess it will not give proper output why because i have 30 columns.
    So could you please give me in report level solution. I am struggling past 10 days for this issue.
    Regards,
    Hari 
    HariKan

  • 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.

  • More Fun with NULLs and Empty Strings

    Greetings,
    I ran across this behavior recently and thought I'd share with the forum. I'm running 10.2.0.2. Note the difference in behavior between passing and explicit NULL in the parameter vice passing an empty string (''):
    CREATE OR REPLACE PROCEDURE NULL_ES_TEST(PARAM1 IN VARCHAR2) IS
    VAR1 CHAR(1);
    BEGIN
    IF PARAM1 IS NULL THEN
    DBMS_OUTPUT.PUT_LINE('PARAM1 IS NULL');
    END IF;
    VAR1 := PARAM1;
    IF VAR1 IS NULL THEN
    DBMS_OUTPUT.PUT_LINE('VAR1 IS NULL');
    ELSE
    DBMS_OUTPUT.PUT_LINE('VAR1 IS NOT NULL');
    END IF;
    DBMS_OUTPUT.PUT_LINE('THE LENGTH OF VAR1 IS '||TO_CHAR(LENGTH(VAR1)));
    END NULL_ES_TEST;
    EXEC NULL_ES_TEST(PARAM1 => '');
    PARAM1 IS NULL
    VAR1 IS NOT NULL
    THE LENGTH OF VAR1 IS 1
    (var1 now holds a single space)
    EXEC NULL_ES_TEST(PARAM1 => NULL);
    PARAM1 IS NULL
    VAR1 IS NULL
    THE LENGTH OF VAR1 IS
    Any Comments or Insights are welcome.
    Sincerely,
    Dale Ward

    Well somethings not as expected (tested on 10.2.0.3)
    Even if you default the parameter to '', it treats null and '' differently.
    SQL> ed
    Wrote file afiedt.buf
      1  CREATE OR REPLACE PROCEDURE NULL_ES_TEST(PARAM1 IN VARCHAR2 := '') IS
      2    VAR1 CHAR(1);
      3  BEGIN
      4    IF PARAM1 IS NULL THEN
      5      DBMS_OUTPUT.PUT_LINE('PARAM1 IS NULL');
      6    END IF;
      7    VAR1 := PARAM1;
      8    IF VAR1 IS NULL THEN
      9      DBMS_OUTPUT.PUT_LINE('VAR1 IS NULL');
    10    ELSE
    11      DBMS_OUTPUT.PUT_LINE('VAR1 IS NOT NULL');
    12    END IF;
    13    DBMS_OUTPUT.PUT_LINE('THE LENGTH OF VAR1 IS '||TO_CHAR(LENGTH(VAR1)));
    14* END NULL_ES_TEST;
    SQL> /
    Procedure created.
    SQL> exec null_es_test(null);
    PARAM1 IS NULL
    VAR1 IS NULL
    THE LENGTH OF VAR1 IS
    PL/SQL procedure successfully completed.
    SQL> exec null_es_test('');
    PARAM1 IS NULL
    VAR1 IS NOT NULL
    THE LENGTH OF VAR1 IS 1
    PL/SQL procedure successfully completed.
    SQL>

Maybe you are looking for

  • Custom list templates not deployed

    Hi everyone, Today I came across a wierd issue while creating some lists in SP 2010 programmatically. I created a few lists schema, list templates and list instances declaratively. I deployed my package and everything seems to work as expected so far

  • Webservice call not working in published PDF form

    I've set up a dropdown field in a standard PDF form and have written the following code to run on the 'On Focus' event: var service = SOAP.connect("http://localhost:50592/lookup.svc?wsdl"); var values = service.GetDropdownValues(); this.getField("Loo

  • Ceo email address required as at my wits end

     Having been advised last march to change to bt business from domestic my company has voluntary folded. I have contacted bt to inform them that the property has been vacated and paid for the termination of contract on top of all the other charges and

  • Problems uploading DeveloperContent.zip

    Hi All I've tried to upload DeveloperContent.zip from Content Management -> ContentExchange -> Package Upload. But I'll get an error ""DeveloperContent.zip" does not exist, or file is empty; you cannot upload empty files". I'm running NW04 SP14, the

  • Error 101215 on some WebDAV messages

    Hello all,           We are sometimes receiving a BEA-101215 error message when trying to send a PROPPATCH WebDAV message to our WebLogic 8.1 SP5 server.           The error only seems to occur when the body of the PROPPATCH message is large: just ch