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.

Similar Messages

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

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

  • I recently bought a new macbook and installed Acrobate Pro. My settings/preferences did not come over and I do not have the same style options for my signature.  It now only allows me three options and the style I have been using for the last year is not

    I recently bought a new macbook and installed Acrobate Pro. My settings/preferences did not come over and I do not have the same style options for my signature.  It now only allows me three options and the style I have been using for the last year is not there.  How do I add additional options and get my preferred signature style back?

    Hi Amanda ,
    Which version of Acrobat are you using?
    Which signature style are you talking about?
    You can go ahead and try uninstalling and reinstalling it and see if that works for you .
    Use the cleaner tool to uninstall it .Here is the link.
    Download Adobe Reader and Acrobat Cleaner Tool - Adobe Labs
    You can refer to the following link to re install it .
    https://helpx.adobe.com/acrobat/kb/acrobat-downloads.html
    Regards
    Sukrit Dhingra

  • Oracle, Null and empty Strings

    Currently I'm facing problems with a class, which contains a String, which
    is set to "" (empty String).
    When the class is persistent, oracle writes null to the table column
    (which seems to be common oracle behaviour) and when retrieving the class,
    the field is set to null as well, giving me a lot of null-pointer
    exceptions.
    Anyway ... I can cope with that (just a lot of extra work)
    far worse is the problem, wenn searching objects, that have this field set
    to "" oder null.
    Oracle can't find the records because JDO creates Querys "where
    string=null" or "where string=''" , where oracle expects "where string is
    null" to find the records.
    Is there a workaround or solution ?

    Yeah, that would work as well, thx, but since I have to cope with
    null-Strings now everywhere in my program, it doesn't hurt just to forbid
    empty strings on the program side.
    In future times I'll test on Oracle first, then porting to DB/2 - this way
    I suppose work is far less to garant compability.
    Nevertheless ... having to set the bankcode into quotes is a kodo bug in
    my opinion.
    Kodo knows the type of classfields (in this case string) and shouldn't
    send the parameter as a BigDecimal to the database.
    Given that, and having only bankcodes of null (only neccesary when using
    Oracle), the method would look like:
    public Collection getAccounts (String bankCode)
    throws Exception
    return getAccounts (Account.class, "bankcode=="+bankcode);
    which is how a transparent persistent layer, um, should be , um , I mean
    ... just transparent ;-D
    Marc Prud'hommeaux wrote:
    Stefan-
    Couldn't you just do something like:
    public Collection getAccounts (String bankCode)
    throws Exception
    String filter;
    if (bankCode == null || bankCode.length () == 0)
    filter = "(bankCode == null || bankCode == "")";
    else
    filter = "bankCode == "" + bankCode + """;
    return getAccounts (Account.class, filter);
    If I understand the problem correctly, this should work for all the
    databases.
    In article <[email protected]>, Stefan wrote:
    What operations are you performing to cause this SQL to be issued? You
    say you are having trouble removing objects, but this is clearly not a
    DELETE statement. Is this the SQL that is issued when looking up
    objects by identity?I'm not removing objects, I was removing just quotes from parameters ;-)
    A string column... is it also represented as a string field in your class?Yeah ... just to give you an impression of the code:
    First we have a class, representing a bank account:
    public class Account {
    private AccountMgr myAccountMgr;
    private String bankCode;
    private String id;
    Note, that in nearly all cases bankCode will be a number or null.
    I have a second class "AccountMgr", which does all of the persistant stuff
    (seaching, making persistent etc.)
    This class has two methods, one versatile (protected) to retrieve accounts
    by a given filterString and one who just returns accounts by bankCode,
    building the expected filterstring. Here is my current working version:
    public class AccountMgr {
    public Collection getAccounts(String bankCode) throws Exception {
    if (bankCode!=null) {
    if (bankCode.equals("")) {
    throw new Exception("check code, bankCode='' not allowed to get
    same behavior from DB2 and Oracle");
    // if set, quote the bankCode
    bankCode="""+bankCode+""";
    return getAccounts(Account.class,"bankCode=="+bankCode);
    protected Collection getAccounts(Class accountClass, String filterAdd)
    throws Exception {
    PersistenceManager pm = MyHelper.getPersistenceManager();
    String filter="";
    if (filterAdd!=null && !filterAdd.trim().equals("")) {
    filter+=filterAdd + " && ";
    filter += "myAccountMgr==_accMgr";
    Query query = pm.newQuery(accountClass, filter);
    query.declareParameters("AccountMgr _accMgr");
    return (Collection) query.execute(this);
    As you can see, in the first method I have to set the bankCode into
    quotes, when it's not null.
    This is because otherwise a filter like "bankCode=1234" will be translated
    in a way, where 1234 is send as a BigDecimal to the database:
    [...] executing statement <4239745>: (SELECT [...] FROM JDO_ACCOUNT t0
    WHERE t0.BANKCODE = ? : [reused=1;params={(BigDecimal) 1234}]
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • Calendar app and calendar notification not in the same time zone

    Hi,
    I just update my macbook pro 13' retina to Yosemite.
    I sync my calendars account (gmail, icloud and exchange) with the calendars apps to have all my event in the notification bar.
    I just see that the event are not at the same hour (see picture)
    Today, in Europe we change from the summer to the winter hour,
    Is it the reason why ? is it a bug ? Am I the only one ?
    Thanks
    Thomas

    I have a similar issue. Events sent to me from Outlook users or created by me in Outlook 2011 (on my Mac) appear 13 hours later in iCal both on my Mac and on my iPhone.
    It seems that iCal in both OS X 10.10 and IOS 8.2 are defaulting inbound events to GMT or UTC time zone despite time zones on both devices being set to my time zone in NZ which is currently GMT/UTC +13.
    It would appear that you are in Europe. Is your time zone by chance 1 hour different from GMT/UTC??

  • How to distinguish NULL and Empty Strings

    Hi,
    Just to set the context right; I'm an experienced C programmer trying labview for the first time. As such I ran in to a problem being that Labview has no concept of NULL-pointers and more specifically appears to have no concept of the difference between a NULL-string and an empty-string
    I'm trying to make a structure (bundle) of strings (in it's most basic form key-value pairs) which i'd like to (for instance) URI encode in order to send it to a web server. For those who are not familiar with URI encoding; there is a distinguished difference between setting a key to an empty string and setting a key with no value. In C I would use a pointer to an empty string vs a NULL string pointer to symbolize this.
    In essence I need an elegant way to distinguish between a defined but empty string and an undefined string (hmmm this is actually describing the same problem but now in terms of perl).
    Anybody have any pointers (pun not intended) for me ?

    This is a bit depending on the interface you have with your encoder. The whole issue is that LV has no pointers at all (and you will like it, as you will never have any Null-Pointer exeptions and the like).
    Assuming that you use a dll (so the Call Library node).
    Use CString as input -> NULL-Terminated String.
    Use I32 as input and pass 0 -> NULL string.
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

  • NULL and Empty String

    Hi There,
    As far as I know, Null is not the same as an empty string; however, when I try this out, I get some unexpected results (well, at least unexpected for my liking):
    SQL> CREATE TABLE TS (MID NUMBER,
      2  MDESC VARCHAR2(20) DEFAULT '' NOT NULL);
    Table created.
    SQL> INSERT INTO TS VALUES(1,'');
    INSERT INTO TS VALUES(1,'')
    ERROR at line 1:
    ORA-01400: cannot insert NULL into ("TT"."TS"."MDESC")So, according to the above scenario, I can't insert an empty string!! However, an empty string is a valid string that doesn't have tuples/data!!
    How come Oracle translates the null string '' as NULL?
    Thanks

    William Robertson wrote:
    There is a special case to do with CHAR values, whereby '' counts as a string and so gets blank-padded, whereas NULL does not.Are you referring to:
    SQL> DECLARE
      2      flag CHAR(2);
      3      PROCEDURE check_null (p_flag IN CHAR)
      4      IS
      5      BEGIN
      6        IF p_flag = '  '
      7        THEN
      8          dbms_output.put_line ('flag is equal to ''  ''');
      9        ELSIF p_flag IS NULL
    10        THEN
    11          dbms_output.put_line ('flag is null');
    12        ELSE
    13          dbms_output.put_line ('other');
    14        END IF;
    15      END;
    16    BEGIN
    17      flag := '';
    18      check_null (flag);
    19      flag := NULL;
    20      check_null (flag);
    21    end;
    22  /
    flag is equal to '  '
    flag is null
    PL/SQL procedure successfully completed.
    SQL> alter session set events '10932 trace name context forever, level 16384';
    Session altered.
    SQL> DECLARE
      2      flag CHAR(2);
      3      PROCEDURE check_null (p_flag IN CHAR)
      4      IS
      5      BEGIN
      6        IF p_flag = '  '
      7        THEN
      8          dbms_output.put_line ('flag is equal to ''  ''');
      9        ELSIF p_flag IS NULL
    10        THEN
    11          dbms_output.put_line ('flag is null');
    12        ELSE
    13          dbms_output.put_line ('other');
    14        END IF;
    15      END;
    16    BEGIN
    17      flag := '';
    18      check_null (flag);
    19      flag := NULL;
    20      check_null (flag);
    21    end;
    22  /
    flag is null
    flag is null
    PL/SQL procedure successfully completed.
    SQL> SY.
    P.S. Don't ask me why normal (or at least consistent) behavior is not the default.

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

  • 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

  • I am using Outlook 2010 and have a iphone 4s.  In Outlook I have issues with my contacts not being the same as what I have corrected them to be.  Is there a way to check and see which file Outlook is sharing with I-cloud?

    I am using Outlook 2010 and I also use a Iphone 4s. I use Outlook to correct all my contacts and them it sync with my phone BUT I get different variations of the contacts.  Almost as if there is another file it is going to.  Can I check to see which file it is reading from??

    This may be helpful.
    http://itconflict.com/2012/01/08/troubleshooting-icloud-sync-with-outlook/

  • How can I transfer files between a PC and a Mac NOT on the same network?

    I have an iCloud account, a Time Capsule and a Seagate Free Agent portable hard drive. Which ways can I transfer files (any or all three?) and how?  Here's my dilemma: I'm a graphic designer and I work on a PC at my office. At home I use my MacBook Pro...same programs, save files. However, I had trouble earlier saving my new documents onto the Free Agent from my MacBook Pro as the Free Agent was Read Only and original files on it were from the PC. The PC is not on my Time Capsule network and not accessible or even close to my MacBook. I simply want to be able to save the files I updated/changed on my Mac to somewhere that I can access them later from that PC...right now they are saved to my Documents folder. Any help is greatly appreciated. Thanks!

    Format the external drive as FAT32 or ExFAT. Both computers will then be able to read and write to it.

  • Preview and Generate view not displaying the same as design view

    RoboHelp HTML Ver 8.0.2.208.
    Hi all,
    I have a topic that will not generate or preview what is displayed in the design view.
    The topic is a table that uses a different image as the background for each cell (from the CSS).
    The background images display fine in design view but will not display when previewed or generated. Everything else is displayed but not the backgrounds.
    Any ideas.
    Thanks
    Wowronin

    You have this -
    </head>
    <script>
    <!--
    function msgopen(url, name, w, h)
    w += 32;
    h += 96;
    var win = window.open(url,
      name,
      'width=' + w + ', height=' + h + ', ' +
      'location=no, menubar=no, ' +
      'status=no, toolbar=no, scrollbars=yes, resizable=yes,screenX=2,screenY=2,left=100,top=100,');
    win.resizeTo(w, h);
    win.focus();
    // -->
    </script>
    <style type="text/css">
    #preloader  {
         position: absolute;
         top: 0;
         left: 0;
         right: 0;
         bottom: 0;
         background-color: #fefefe;
         z-index: 99;
        height: 100%;
    #status  {
         width: 200px;
         height: 200px;
         position: absolute;
         left: 50%;
         top: 50%;
         background-image: url(ajax-loader.gif);
         background-repeat: no-repeat;
         background-position: center;
         margin: -100px 0 0 -100px;
    </style>
    <body>
    In other words, you have a script block AND a CSS block between </head> and <body>. That's invalid code. Move it to where it belongs inside the <head> region.  You could have found this in an instant by checking the page here - http://validator.w3.org.

  • Video And Audio does not have the same length

    Hello
    i have a problem. For DVD i am working on, i create my Movies for menus in Flash. I sync Video animation and audio in Flash, and export all in QT. Then i take my QT and export in M2V and AIFF. Then i use A.PACK to export in AC3.
    But i always get a white part (around 1 sec) in the end of my movie. I cut it in QT, but then get it again after the m2v export.
    Each time i get a AC3 lenght different from the video. Say the AC3 file is 24 second long, and the movie is 23:13. Of course, when i try to make a loop in DDVSP(3) my music is cut OR i have a white display before looping. What is the problem ? How can i correct this ?

    never found a solution ..

  • [TroubleShooting]Continuity Wi-Fi issue. iPhone and mac not on the same wifi network

    Ive been following this and other forums since Yosemite came out few weeks back & i can see many other people are having this issue as well.
    The issue is that I'm not able to make/receive calls on my MBP using my iPhone via continuity.
    Ive tried all of the possible solutions made here and elsewhere on how to resolve this issue. [playing about with settings and iCloud]
    When I'm at home all of the handoff and continuity features work apart from making and receiving calls. Tells me my mac and iPhone are not on the same wifi network, even though they are.
    Now, the solution?
    Now this is where tourbleshooting comes in. Ive taken my mac and to my homegirls house & all of the features worked including phonecalls, without changing anything, except?? THE ISP and the router at her house.
    Personally i live in London, Uk. At home i have sky, and my girl has TalkTalk.
    So im 99.9% sure this has nothing to do with the OS X, but rather its the ISP or the router.
    Now I'm asking for help from anyone that understands the ISP's and routers, on what kind of issue there might be. Im no computer wiz kid, but I'm guessing it could be something that has to do with the NAT type. (Call of duty on ps3 haha) At my house its moderate and my homegirls - open? could that be the issue? if so are there any router settings i can play about to see if that solves the issue?
    Thanks.
    Please only post if you know what you're talking about because i don't want anyone giving me some next instructions for my router so i end up without internet what so ever haha And whoever is having the same problem, id appreciate if you'd post on this to keep the post alive

    Hey chrisfromdc,
    If you are having an issue with your Mac being unregistered with iMessage and FaceTime, I would suggest that you troubleshoot using the steps in this article - 
    If you have difficulty activating FaceTime or iMessage - Apple Support
    Thanks for using Apple Support Communities.
    Be well,
    Brett L 

Maybe you are looking for

  • FiOS TV: First Impressions of a New Customer

    I’ve been a DirecTV customer for about 10 years. D* has been my primary provider except for 2 years when Dish Network was. I had switched to E* because D* had something like 12 HD channels while E* had the VOOM Network channels. I dropped E* like a h

  • Why can't i write text directly in a Pages document without using a text box ?

    Hello buddies, Once upon a time, when I was running Leopard on my MB black, I was able to open a Pages document and type text directly without creating a textbox. That was a great way to take notes during a meeting or to past a long document in, with

  • Set_block_property and Default_where

    Hi All, I'm trying to set the default clause at runtime,for that i'm using set_block_properties. Here is my cde: Set_block_property('RECIPIENT_VIEW',DEFAULT_WHERE,'RECIPIENT_NAME LIKE '||''''||:RECIPIENT_NAME ||'%'||''''); I'm NOT getting if i use th

  • Regarding the File Format on the application server

    Hi, I would like to know the file format (ANSI, UTF-8, UTF-16, UTF-32) of the file placed on the application server in my program. Can anyone help me with the Function Module or Class or any other way which will retrieve this information. Thanks Sarv

  • Basic Authentication in WebService

    Hi,    I am trying to authenticate in web service with basic authentication but I can not.    The code:    var w:WebService = new WebService();    var encoder:Base64Encoder = new Base64Encoder();    encoder.insertNewLines = false;    encoder.encode("