Empty strings and nillable

I have the following:
<xs:element name="AString" nillable="true" type="xs:string" minOccurs="0" maxOccurs="1"/>
What I want is that when I call getAString() that this will return nulll if I
have not set the value.
At the moment it returns an empty string.
Thanks in advance,
Andrew

Hi Andrew,
can you provide a sample?
I tried what you said and I am getting null. Below is what I tried.
Lets say I have an xsd
<?xml version="1.0"?>
<xs:schema
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns:bea="http://www.bea.com/xmlbeans/Sample.xsd"
     targetNamespace="http://www.bea.com/xmlbeans/Sample.xsd"
     elementFormDefault="qualified"
     attributeFormDefault="unqualified">
<xs:element name="Person">
<xs:complexType>
<xs:sequence>
<xs:element name="FirstName" type="xs:string" />
<xs:element name="LastName" nillable="true" type="xs:string" minOccurs="0"
maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
and below is the code:
PersonDocument personDoc = PersonDocument.Factory.newInstance();
Person person = personDoc.addNewPerson();
person.setFirstName("Mike");
System.out.println("person.getLastName()"+ person.getLastName());
It prints null
Output:
person.getLastName()null
This is on WLW8.1Sp2.
Thanks a lot,
Vimala Ranganathan
"Andrew" <[email protected]> wrote:
>
I have the following:
<xs:element name="AString" nillable="true" type="xs:string" minOccurs="0"
maxOccurs="1"/>
What I want is that when I call getAString() that this will return nulll
if I
have not set the value.
At the moment it returns an empty string.
Thanks in advance,
Andrew

Similar Messages

  • How to check empty string and null? Assign same value to multiple variables

    Hi,
    1.
    How do I check for empty string and null?
    in_value IN VARCHAR2
    2. Also how do I assign same value to multiple variables?
    var_one NUMBER := 0;
    var_two NUMBER := 0;
    var_one := var_two := 0; --- Gives an error
    Thanks

    MichaelS wrote:
    Not always: Beware of CHAR's:
    Bug 727361: ZERO-LENGTH STRING DOES NOT RETURN NULL WHEN USED WITH CHAR DATA TYPE IN PL/SQL:
    SQL> declare
      2    l_str1   char (10) := '';
      3    l_str2   char (10) := null;
      4  begin
      5  
      6    if l_str1 is null
      7    then
      8      dbms_output.put_line ('oh STR1 is null');
      9    elsif l_str1 is not null
    10    then
    11      dbms_output.put_line ('oh STR1 is NOT null');
    12    end if;
    13  
    14    if l_str2 is null
    15    then
    16      dbms_output.put_line ('oh STR2 is null');
    17    elsif l_str2 is not null
    18    then
    19      dbms_output.put_line ('oh STR2 is NOT null');
    20    end if;
    21  end;
    22  /
    oh STR1 is NOT null
    oh STR2 is null
    PL/SQL procedure successfully completed.
    SQL> alter session set events '10932 trace name context forever, level 16384';
    Session altered.
    SQL> declare
      2    l_str1   char (10) := '';
      3    l_str2   char (10) := null;
      4  begin
      5  
      6    if l_str1 is null
      7    then
      8      dbms_output.put_line ('oh STR1 is null');
      9    elsif l_str1 is not null
    10    then
    11      dbms_output.put_line ('oh STR1 is NOT null');
    12    end if;
    13  
    14    if l_str2 is null
    15    then
    16      dbms_output.put_line ('oh STR2 is null');
    17    elsif l_str2 is not null
    18    then
    19      dbms_output.put_line ('oh STR2 is NOT null');
    20    end if;
    21  end;
    22  /
    oh STR1 is null
    oh STR2 is null
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Varchar2, empty strings and NULL

    Hi all,
    When inserting an empty string into a column of type varchar2 - is a NULL value stored in the column by the database? I've seen conflicting reports, and I know that the SQL 1992 spec specifies that empty strings not be treated as a NULL value, but that Oracle has traditionally treated zero length strings stored in a varchar2 column as NULL.
    So, is there a way to store an empty string in a varchar2 column as an empty string and not a NULL value?
    TIA,
    Seth

    It can be even more complicated or annoying than NULL not equal to ASCII NULL.
    example:
    create table test_null
    (fld1 varchar2(10),
    fld2 varchar2(10),
    fld3 varchar2(20));
    insert into test_null values (chr(0),null, 'chr(0) and null');
    insert into test_null values (null, null, 'null and null');
    insert into test_null values ('', chr(0), ''''' and chr(0)');
    insert into test_null values ('', null, ''''' and null');
    select * from test_null;
    FLD1       FLD2       FLD3
                          chr(0) and null
                          null and null
                          '' and chr(0)
                          '' and null
      1  DECLARE
      2  BEGIN
      3   for c1 in (select fld1, fld2, fld3 from test_null) loop
      4      if c1.fld1 = c1.fld2 then
      5         dbms_output.put_line(c1.fld3||' Are equal'||
      6                '  Length fld1 = '||to_char(length(c1.fld1))||
      7                ' Length fld2 = '||to_char(length(c1.fld2)));
      8      else
      9         dbms_output.put_line(c1.fld3||' Are NOT equal'||
    10                '  Length fld1 = '||to_char(length(c1.fld1))||
    11                ' Length fld2 = '||to_char(length(c1.fld2)));
    12      end if;
    13      dbms_output.put_line(' ');
    14   end loop;
    15*  END;
    SQL> /
    chr(0) and null Are NOT equal  Length fld1 = 1 Length fld2 =
    null and null Are NOT equal  Length fld1 =  Length fld2 =
    '' and chr(0) Are NOT equal  Length fld1 =  Length fld2 = 1
    '' and null Are NOT equal  Length fld1 =  Length fld2 =
    PL/SQL procedure successfully completed.

  • Distinguishing between empty string and null values

    hi all,
    I am using an ODBC connection to connect my java app to database using JDBCODBC driver. I have 2 columns 'aColumn' and 'bColumn' in my table, both allow null values. I have one row in it, which has null value in aColumn and empty string in bColumn. I retrieve this row's data and assign it to 2 columns : 'aColumnVar' and 'bColumnVar' respectively. I find out that both 'aColumnVar' and 'bColumnVar' variables has null values (although bColumnVar should has an empty string as its value). Now my ODBC connection Data Source has the option "Use ANSI nulls, paddings, and warnings" ON. I turn it off and try again. This time both 'aColumnVar' and 'bColumnVar' variables has empty string as values (although aColumnVar should has null as its value).
    How can I make sure that i can get the data exactly as it is in the database in my variables?
    Thanks

    there is a wasNull() method on ResultSet. After you
    have obtained the value of a column e.g. by calling a
    method like getString you can call wasNull and if it
    returns true then the value on the database is null.
    Check the java docs, it might explain it better
    http://java.sun.com/j2se/1.4.1/docs/api/java/sql/Result
    et.html#wasNull()I am using MS SQL Server 7.0 under Windows NT 4.0 with JDK 1.2. My ODBC connection Data Source has to have the option "Use ANSI nulls, paddings, and warnings" ON.
    I try the wasNull() method but it is doing the same thing i.e. telling me that a column is null when in database it is null (right); and a column is null when in database it is an empty string (wrong). I suspect it is something to do with the JDBC-ODBC driver I am using.

  • Empty string and NULL value

    Hi,
    Does oracle treat empty string as NULL.
    If it is so,Can we force db to treat both as different things.
    Thanx

    11g.DBA wrote:
    Hi,
    Does oracle treat empty string as NULL.Yes.
    If it is so,Can we force db to treat both as different things.No.
    Please read in SQL Reference:
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/sql_elements005.htm#SQLRF3003

  • Is empty string and Null same?

    create table x
    (empid number);
    Table created.
    insert into x values ('');
    1 row created.
    insert into x values (null);
    1 row created.
    SQL> set null <<>>
    SQL> select * from x;
         EMPID
    <<>>
    <<>>So i can safely change an Insert statement like
    insert into x values ('');to
    insert into x values (null);Right?

    michaels2 wrote:
    char pads with spaces to the length of the data itemdon't think so - at least not on my 11.2.0.1.0Good. Oracle finally fixed it. Before 11.2 it was pretty much as ajallen noted:
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    SET SERVEROUTPUT ON
    DECLARE
        flag CHAR(2);
        PROCEDURE check_null (p_flag IN CHAR)
        IS
        BEGIN
          IF p_flag = '  '
            THEN
              dbms_output.put_line ('flag is equal to ''  ''');
            ELSIF p_flag IS NULL
              THEN
                dbms_output.put_line ('flag is null');
            ELSE
              dbms_output.put_line ('other');
          END IF;
        END;
    BEGIN
        flag := '';
        check_null (flag);
        flag := NULL;
        check_null (flag);
    END;
    flag is equal to '  '
    flag is null
    PL/SQL procedure successfully completed.
    alter session set events '10932 trace name context forever, level 16384';
    DECLARE
        flag CHAR(2);
        PROCEDURE check_null (p_flag IN CHAR)
        IS
        BEGIN
          IF p_flag = '  '
            THEN
              dbms_output.put_line ('flag is equal to ''  ''');
            ELSIF p_flag IS NULL
              THEN
                dbms_output.put_line ('flag is null');
            ELSE
              dbms_output.put_line ('other');
          END IF;
        END;
    BEGIN
        flag := '';
        check_null (flag);
        flag := NULL;
        check_null (flag);
    END;
    flag is null
    flag is null
    PL/SQL procedure successfully completed.
    SQL>
    Bug 727361: ZERO-LENGTH STRING DOES NOT RETURN NULL WHEN USED WITH CHAR DATA TYPE IN PL/SQL
    SY.

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

  • StringTokenizer vs. split and empty strings -- some clarification please?

    Hi everybody,
    I posted a question that was sort of similar to this once, asking if it was best to convert any StringTokenizers to calls to split when parsing strings, but this one is a little different. I rarely use split, because if there are consecutive delimiters, it gives empty strings in the array it returns, which I don't want. On the other hand, I know StringTokenizer is slower, but it doesn't give empty strings with consecutive delimiters. I would use split much more often if there was a way to use it and not have to check every array element to make sure it isn't the empty string. I think I may have misunderstood the javadoc to some extent--could anyone explain to me why split causes empty strings and StringTokenizer doesn't?
    Thanks,
    Jezzica85

    Because they are different?
    Tokenizers are designed to return tokens, whereas split is simply splitting the String up into bits. They have different purposes
    and uses to be honest. I believe the results of previous discussions of this have indicated that Tokenizers are slightly (very
    slightly and not really meaningfully) faster and tokenizers do have the option of return delimiters as well which can be useful
    and is a functionality not present in just a straight split.
    However. split and regex in general are newer additions to the Java platform and they do have some advantages. The most
    obvious being that you cannot use a tokenizer to split up values where the delimiter is multiple characters and you can with
    split.
    So in general the advice given to you was good, because split gives you more flexibility down the road. If you don't want
    the empty strings then yes just read them and throw them away.
    Edited by: cotton.m on Mar 6, 2008 7:34 AM
    goddamned stupid forum formatting

  • 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

  • Setting input fields to an empty string BIG PROBLEM

    Hi Rob, thanks for your rerply, It makes sense alright, but I am using 2 seperate input fields. I have discovered what is causing the problem .
    After the user types into the inputfield and moves on to a different frame, I have set the input field to an empty string and this is what is causing the problem.
    I have tried setting the input field to an empty string in a movie script and on individual sprites and the first right answer is not excepted.I have to type in the right answer twice to get get a right response. I am actually using three seperate input fields in total, each with a different name and behavior. Even If I use one input field I still have the same problem. Its driving me crazey. Any Ideas.
    Anne

    I believe that the FIM Service always does trims on string, so you may be out of luck.
    What is your scenario / what are you trying to accomplish by setting a space in an attribute? A space is not an empty string in my definition.
    Regards, Soren Granfeldt
    blog is at http://blog.goverco.com | facebook https://www.facebook.com/TheIdentityManagementExplorer | twitter at https://twitter.com/#!/MrGranfeldt

  • SQLLDR - how to set a default value for an empty string

    I'm using SQLLDR to load data from a flat file on Oracle 10g 10.2.0.4 EE, Linux RHEL 4 update 6. Seems like my question is simple, but darned if I can't find the solution.
    My source file (comma delimited extracted form a different RDBMS) has some (not all) rows where the output for a string is "", and not NULL. How do I check for empty string and add a default value in the control file? The target column is non-nullable
    Here's my current control file - however, the column attributeName where sometimes the source record is "" does not get evaluated as NULL.
    load data
    infile 'mydata.del'
    badfile 'mydata.bad'
    discardfile 'mydata.dsc'
    into table mydata
    fields terminated by "," optionally enclosed by '"'
       TRAILING NULLCOLS           
    (l_metadata,
    company,
    className,
    attributeName "decode(:vc_attributeName,null, 'none')",
    attributeDefault)
    {code}
    When I tried decode with "", I received the following error:
    {code}SQL*Loader-350: Syntax error at line 11.
    Expecting "," or ")", found ", 'none')".
    attributeName "decode(:vc_attributeName,"", 'none')", {code}
    This does not work either:
    {code}
    load data
    infile 'mydata.del'
    badfile 'mydata.bad'
    discardfile 'mydata.dsc'
    into table mydata
    fields terminated by "," optionally enclosed by '"'
       TRAILING NULLCOLS           
    (l_metadata,
    company,
    className,
    attributeName NULLIF attributeName = BLANKS ,"decode(:vc_attributeName,null, 'none')",
    attributeDefault) I get the following in the log:
    Table COMPANYMETADATA, loaded from every logical record.
    Insert option in effect for this table: INSERT
    TRAILING NULLCOLS option in effect
       Column Name                  Position   Len  Term Encl Datatype
    L_METADATA                          FIRST     *   ,  O(") CHARACTER
    COMPANY                            NEXT     *   ,  O(") CHARACTER
    CLASSNAME                         NEXT     *   ,  O(") CHARACTER
    ATTRIBUTENAME                     NEXT     *   ,  O(") CHARACTER
        NULL if ATTRIBUTENAME = BLANKS
        SQL string for column : "decode(:attributeName,null, 'none')"
    ATTRIBUTEDEFAULT                  NEXT     *   ,  O(") CHARACTER
    Record 1: Rejected - Error on table COMPANYMETADATA, column ATTRIBUTENAME.
    ORA-01400: cannot insert NULL into ("SRV5"."COMPANYMETADATA"."ATTRIBUTENAME")
    {code}
    Any help is appreciated -
    Edited by: kpw on Feb 9, 2009 11:10 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hello,
    I just loaded following data successfully in my_data table using the same control file I posted. Yes it will evaluate "" as null and replace with none, remember in control file you have this option, "optionally enclosed by '"'.
    #my_data.dat
    "myname1", "attribname1"
    "myname2", "attribname2"
    "myname3", "attribname3"
    "myname4", ""
    #my_data.ctl
    load data
    into table my_data
    fields terminated by "," optionally enclosed by '"'
    TRAILING NULLCOLS           
    my_name char(30),
    vc_attributeName "decode(:vc_attributeName,null, 'none', :vc_attributeName)"
    {code}
    Here is the output log file
    {code}
    Control File:   my_data.ctl
    Data File:      mydata.dat
      Bad File:     mydata.bad
      Discard File:  none specified
    (Allow all discards)
    Number to load: ALL
    Number to skip: 0
    Errors allowed: 50
    Bind array:     64 rows, maximum of 256000 bytes
    Continuation:    none specified
    Path used:      Conventional
    Table MY_DATA, loaded from every logical record.
    Insert option in effect for this table: INSERT
    TRAILING NULLCOLS option in effect
       Column Name                  Position   Len  Term Encl Datatype
    MY_NAME                             FIRST    30   ,  O(") CHARACTER           
    VC_ATTRIBUTENAME                     NEXT     *   ,  O(") CHARACTER           
        SQL string for column : "decode(:vc_attributeName,null, 'none', :vc_attributeName)"
    Table MY_DATA:
      4 Rows successfully loaded.
      0 Rows not loaded due to data errors.
      0 Rows not loaded because all WHEN clauses were failed.
      0 Rows not loaded because all fields were null.
    Space allocated for bind array:                  18560 bytes(64 rows)
    Read   buffer bytes: 1048576
    Total logical records skipped:          0
    Total logical records read:             4
    Total logical records rejected:         0
    Total logical records discarded:        0
    Run began on Mon Feb 09 18:17:35 2009
    Run ended on Mon Feb 09 18:17:36 2009
    Elapsed time was:     00:00:00.98
    CPU time was:         00:00:00.10
    {code}
    Hope this helps clearing your dobuts
    Regards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Problem: textbox leave empty string("") instead of null

    Hello, I have a problem with textboxes. By default, they always are initialized to null, but when I start entering and removing data from textboxes, many times they leave an empty string "" instead of null.
    And, of course, it's not the same a null value as an empty string and thus, I haven't got the expected result in queries to database.
    Thus, I always have to compare textbox values with "" and null. It's very tedious and not elegant solution. I would like to know if there is another way to get the values as null instead of empty strings.

    Yes. Once you entered and remove the text it will evaluated as you told .
    For ur case u can Try the condition as
    if ( instance !=null && instance.length !=0)
    be sure instance != null check b4 other wise u can get NullPointerException

  • Empty string == NULL ???!?!?!?!??!

    Hi SQlers ...
    I'm using Oracle 8.1.7 ... and Oracle maps the literal empty
    string value, to the NULL value ... it that the expected result?
    simple example:
    SELECT 1 from dual where ('' is null)
    I've tried the same on others rdbms, and of course, the
    result is not the same.
    thanks in advance
    saludos
    dario estepario ...

    Yup. In Oracle the empty string '' and NULL are identical, though they periodically threaten that this may change in the future.
    Justin

  • 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

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

Maybe you are looking for

  • Scanning different size documents.

    I need to scan letter and legal size documents into one PDF. I have adjusted the presets to Automatic in the paper size section but it only scans them to letter. Help!

  • Download Image with DBMS_LOB

    I want to download the image file stored in database with the DBMS_LOB package within the forms 6i application. The DBMS_LOB.READ can do this but the buffer limit is 32kB! The image file I want to download is with size over 10MB, so that I need to wr

  • Long text uploading problem in BDC

    Hai Gurus please help me, it is urgent i want to upload more than 200 characters filed from flat file to every inspection lot record usage decision(QA11) through BDC for every inspection lot Brief description about my problem:   in the transaction QA

  • How can i apply different color for each cell in jlist component?

    hi guys i need your help and sorry if my english is very bad..guys how can i apply different colors for each cell in jlist component? for example for the first cell i want to apply color blue, for the second cell i want red, etc... i need your answer

  • Unix commandlines for ARD

    I am looking for some help using ?Unix command lines and shell scripts with ARD. Is this the best forum for that....for example I am trying to start an ASR server remotely from ARD on a OS X.4 server...When I drag the script to terminal and start it