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

Similar Messages

  • Empty string in NOT NULL column

    I'm migrating data to Oracle 9i from a database engine that supports emtpy strings in column with NOT NULL specified in the DDL. I would have thought Oracle would support this, but any attempt to put empty string data into a column created with NOT NULL is returning a 'column does not support nulls'-type error.
    Is there an option to allow this, or does Oracle simply not support this and assumes blank is null?
    Thanks

    I would have thought Oracle would support this, but any attempt to put empty string data into a column created with NOT NULL is returning a 'column does not support nulls'-type error.In Oracle Null means null nothing not even an empty String.
    Yes DB's like Ingress supports this. But I think Oracle is right.
    Is there an option to allow this, or does Oracle simply not support this and assumes blank is null?I am not aware of any options as it is against the basic principles.
    you can find work arounds to do the migration. But storing a blank NO.
    Good Luck
    Vij

  • Empty strings morphed to NULL ???

    Hi all,
    I am executing the following SQL-statement (short version):
    statement = (OraclePreparedStatement)
    connection.prepareStatement(
    "INSERT INTO TEST VALUES (?)");
    statement.defineColumnType(1, OracleTypes.VARCHAR);
    statement.setString (1,"");
    statement.execute();
    statement.close();
    connection.commit();
    Then I have a look into the table TEST (with SQL-PLUS) and see
    that my stringValue "" morphed to a NULL-value !!!
    Why are "" Strings mapped to NULL ???
    Is there a configuration-parameter to turn this "feature" off ???
    "" is not the same as NULL, is it ???
    Thank You in advance,
    Ralf.
    null

    Ralf Severloh (guest) wrote:
    : Why are "" Strings mapped to NULL ???
    This is a known Oracle feature / bug (depending on your
    perspective). Null strings are equal to null. Try "SELECT 1 FROM
    dual WHERE '' IS NULL;" to prove it.
    : Is there a configuration-parameter to turn this "feature" off
    Not as far as I know.
    : "" is not the same as NULL, is it ???
    Not to my way of thinking, however Oracle disagrees.
    --> Steve
    null

  • PreparedStatement and empty String instead of space

    Hi all, I would test a space value in a varchar field, i.e.:
    PreparedStatement ps=con.prepareStatement();
    String qry = "select a from table where b=? and c=?";
    ps.setString(1,"value");
    ps.setString(2," "); // space!!
    That source code doesn't work: it set "" (empty String) in the second field, not " " (space).
    Can I use PrepareStatement in any way to do this or I have to use only Statement?
    Thanks.
    Bye.

    my friend, the question was: how do you know the
    parameter is set to "" (empty string)?I don't know: I suppose!!! because it's the only reason for that it returns no record. I tested my query in this three ways:
    1) directly in sqlplus: SELECT OCCFASE As fase, OCLCVVC as convRat, SUM(QTA1) As qta1UM, SUM(QTA2) As qta2UM
    FROM DJITMPRE WHERE OCCFASE IN ('I','P') AND OCCCOSC='XXXXX' AND OCCITEM='RUG-02' AND OCCTPVR = 'RUG'
    AND OCCVAR1 = '01' AND OCCVAR2 = 'WW' AND OCCVAR3 = '12' AND OCCTPIM = '01' AND MAGAZZINO = 'MAG03'
    AND COMMESSA = ' ' AND ORIG = ' ' AND PARTITA = ' ' AND CONFIG = 0.0 AND VANO = ' '
    GROUP BY OCCFASE, OCLCVVC
    and it returns one record.
    2) using Statement:
         Statement s = conn.createStatement();
         String societa=session.getCompanyLogisticName(DSession.TABLE_LOGISTIC);
              StringBuffer qry=new StringBuffer();
              StringBuffer whereClause=new StringBuffer();
              qry.append("SELECT OCCFASE As fase, OCLCVVC as convRat, SUM(QTA1) As qta1UM, SUM(QTA2) As qta2UM ");
              qry.append("FROM DJITMPRE ");
              qry.append("WHERE OCCFASE IN ('I','P') ");
              qry.append("AND OCCCOSC='");
              qry.append(societa);
              qry.append("' ");     
              whereClause.append("AND OCCITEM='");
              whereClause.append(b.getItemCode());
              whereClause.append("' ");
              whereClause.append("AND OCCTPVR = '");
         if (b.getVariantType().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getVariantType(), 1));
         }else{
              whereClause.append(b.getVariantType());
         whereClause.append("' ");
         whereClause.append("AND OCCVAR1 = '");
         if (b.getFirstVariant().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getFirstVariant(), 1));
         }else{
              whereClause.append(b.getFirstVariant());
         whereClause.append("' ");
         whereClause.append("AND OCCVAR2 = '");
         if (b.getSecondVariant().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getSecondVariant(), 1));
         }else{
              whereClause.append(b.getSecondVariant());
         whereClause.append("' ");
         whereClause.append("AND OCCVAR3 = '");
         if (b.getThirdVariant().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getThirdVariant(), 1));
         }else{
              whereClause.append(b.getThirdVariant());
         whereClause.append("' ");
         whereClause.append("AND OCCTPIM = '");
         if (b.getPackingType().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getPackingType(), 1));
         }else{
              whereClause.append(b.getPackingType());
         whereClause.append("' ");
         whereClause.append("AND MAGAZZINO = '");
         if (b.getWarehouseCode().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getWarehouseCode(), 1));
         }else{
              whereClause.append(b.getWarehouseCode());
         whereClause.append("' ");
         whereClause.append("AND COMMESSA = '");
         if (b.getProjectItem().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getProjectItem(), 1));
         }else{
              whereClause.append(b.getProjectItem());
         whereClause.append("' ");
         whereClause.append("AND ORIG = '");
         if (b.getSourceLot().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getSourceLot(), 1));
         }else{
              whereClause.append(b.getSourceLot());
         whereClause.append("' ");
         whereClause.append("AND PARTITA = '");
         if (b.getLotNumber().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getLotNumber(), 1));
         }else{
              whereClause.append(b.getLotNumber());
         whereClause.append("' ");
         whereClause.append("AND CONFIG = ");
         whereClause.append(b.getItemConfiguration());
         whereClause.append("AND VANO = '");
         if (b.getLocation().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getLocation(), 1));
         }else{
              whereClause.append(b.getLocation());
         whereClause.append("' ");
         qry.append(whereClause.toString());
         qry.append(" GROUP BY OCCFASE, OCLCVVC");
    ResultSet rs = s.executeQuery(qry.toString());
    and it returns one record.
    3) using PreparedStatement:
    StringBuffer qry=new StringBuffer();
    qry.append("SELECT OCCFASE As fase, OCLCVVC as convRat, SUM(QTA1) As qta1UM, SUM(QTA2) As qta2UM ");
                   qry.append("FROM DJITMPRE WHERE OCCFASE IN ('I','P') ");
                   qry.append("AND OCCCOSC='").append(societa).append("' ");
                   qry.append("AND OCCITEM=? AND OCCTPVR = ? ");
              qry.append("AND OCCVAR1 = ? AND OCCVAR2 = ? AND OCCVAR3 = ? ");
              qry.append("AND OCCTPIM = ? AND MAGAZZINO = ? AND COMMESSA = ? ");
              qry.append("AND ORIG = ? AND PARTITA = ? AND CONFIG = ? ");
              qry.append("AND VANO = ? ");
              qry.append("GROUP BY OCCFASE, OCLCVVC");
    PreparedStatement bookedQtyPS = conn.prepareStatement(qry.toString());
    bookedQtyPS.setString(1,b.getItemCode());
         if (b.getVariantType().equals("")){
              bookedQtyPS.setString(2,EscapeString.getLengthString(b.getVariantType(), 1));
         }else{
              bookedQtyPS.setString(2,b.getVariantType());
         if (b.getFirstVariant().equals("")){
              bookedQtyPS.setString(3,EscapeString.getLengthString(b.getFirstVariant(), 1));
         }else{
              bookedQtyPS.setString(3,b.getFirstVariant());
         if (b.getSecondVariant().equals("")){
              bookedQtyPS.setString(4,EscapeString.getLengthString(b.getSecondVariant(), 1));
         }else{
              bookedQtyPS.setString(4,b.getSecondVariant());
         if (b.getThirdVariant().equals("")){
              bookedQtyPS.setString(5,EscapeString.getLengthString(b.getThirdVariant(), 1));
         }else{
              bookedQtyPS.setString(5,b.getThirdVariant());
         if (b.getPackingType().equals("")){
              bookedQtyPS.setString(6,EscapeString.getLengthString(b.getPackingType(), 1));
         }else{
              bookedQtyPS.setString(6,b.getPackingType());
         if (b.getWarehouseCode().equals("")){
              bookedQtyPS.setString(7,EscapeString.getLengthString(b.getWarehouseCode(), 1));
         }else{
              bookedQtyPS.setString(7,b.getWarehouseCode());
    //cat.debug("b.getProjectItem(): "+b.getProjectItem());
         if (b.getProjectItem().equals("")){
              //cat.debug("entro in 1 b.getProjectItem().length: "+b.getProjectItem().length());
              bookedQtyPS.setString(8,EscapeString.getLengthString(b.getProjectItem(), 1));
              //bookedQtyPS.setString(8," ");
         }else{
              //cat.debug("entro in 2 b.getProjectItem().length: "+b.getProjectItem().length());
              bookedQtyPS.setString(8,b.getProjectItem());
         bookedQtyPS.setString(8," ");
    //cat.debug("b.getSourceLot(): "+b.getSourceLot());     
         if (b.getSourceLot().equals("")){
              bookedQtyPS.setString(9,EscapeString.getLengthString(b.getSourceLot(), 1));
         }else{
              bookedQtyPS.setString(9,b.getSourceLot());
         bookedQtyPS.setString(9," ");
    //cat.debug("b.getLotNumber(): "+b.getLotNumber());     
         if (b.getLotNumber().equals("")){
              bookedQtyPS.setString(10,EscapeString.getLengthString(b.getLotNumber(), 1));
         }else{
              bookedQtyPS.setString(10,b.getLotNumber());
         bookedQtyPS.setString(10," ");
    //cat.debug("b.getItemConfiguration(): "+b.getItemConfiguration());
         bookedQtyPS.setString(11,""+b.getItemConfiguration());
    //cat.debug("b.getLocation(): "+b.getLocation());     
         if (b.getLocation().equals("")){
              bookedQtyPS.setString(12,EscapeString.getLengthString(b.getLocation(), 1));
         }else{
              bookedQtyPS.setString(12,b.getLocation());
         bookedQtyPS.setString(12," ");
    ResultSet rs = bookedQtyPS.executeQuery();
    and it returns 0 records.
    I hope I explained it well.

  • Empty Strings are converted to NULLs

    We are developing a Java application intended to work with multiple databases. We want to store empty strings but oracle converts this to NULL values. Is there a way to tell the Oracle Database not to convert the empty string to NULL and to store it as an empty string?
    Thanks
    Joaquim Franco <[email protected]>
    GEDI, SA

    Our project started with a MySQL database and the code is full of built queries like "Select Field from table where field = var" where var can be an empty string. It would be easier for us to turn a switch in the database then to look for every query in the application and add code to test is var is empty a change the query to "Select Field from table where field is NULL".
    Best Regards
    Joaquim Franco
    &gt; It is a quirk of Oracle that it regards empty strings
    &gt; and NULLs as being the same thing. This behaviour
    &gt; has been built into the database forever. Oracle
    &gt; keep threatening to change but I suspect they are
    &gt; scared of the impact, not least on their own code.
    &gt; As Oracle increasingly embrace Java they may decide
    &gt; to revisit this - I don't know whether the behaviour
    &gt; is changed in 10G.
    &gt;
    &gt; What sort of problems does it cause you?
    &gt;
    &gt; Cheers, APC

  • Null/Empty Strings use in ESB Database Adapter

    Hi
    I'm trying to use a database adapter to execute an update on a table with a composite primary key; one of the primary key columns sometimes contains an empty string, however whenever I try to call the adapter, it always converts this to a null value. Is there an easy way to force the adapter to use an empty string instead of a null?
    Thanks.

    the idea here is to execute the dbms statement, or the setpolicycontext statement in a db session, and being able to execute the next sql statement in the same db session.
    This is possible with consecutive database adapters sharing the same db session.
    and two db adapters sharing the same db session is possible, if you make sure that the bpel is participating in the db transaction which can be made possible via xa db connections.
    Hope this helps,
    Write back in case you need more info.

  • 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

  • What is in the column, empty string, null or ....?

    I am using Oracle 11.2, have one table tb_class as following:
    TB_CLASS (id number(3), nm varchar2(32), seqNum number(3));
    1, ,212
    2,'as', 12
    3, 'qq', 12
    select * from TB_CLASS where id=1 and nm=null; ...no row selected
    select nvl(nm) from TB_CLASS where id=1; ...1 row selected
    Any one know what is in column nm for row id=1? I thought it is empty string, but why it returns no row in the first query?
    Thanks!

    1) In Oracle there is no difference between NULL and the empty string.
    2) NULL is never equal to anything (including another NULL). NULL is never unequal to anything (including another NULL). You need to use the IS NULL and/ or IS NOT NULL operators in order to look for NULL values
    SELECT *
      FROM tb_class
    WHERE nm IS NULLor
    SELECT *
      FROM tb_class
    WHERE nm IS NOT NULLOf course, it is also possible that you are stating that the NM column contains one or more spaces or that it contains one or more non-printable characters rather than a NULL. That's why you were asked what dump(nm) returns
    Justin

  • Min aggregate function returns empty string

    I have a data set with a column named "month" which contains string values like 1,2,3... etc. including empty string. When I apply an aggregate Min function like below, it returns empty string instead of 1. or the lowest month number.
    Min(Fields!month.Value, "Financial")
    Please if any one can assist me on this.
    Regards

    Hi ABDUL-HAFEEZ,
    As you know the Min() function returns the minimum value of all non-null numeric values specified by the expression, because you have null string in the field and also the field type is string but not numeric, so this function will not works fine.
    I have tested on my local environment that we can get the first convert the string to numeric type value and then get the min value of the month field by using the query not the expression.
    Details information below for your reference:
    Create an new dataset(DataSet2) to get the minimum value from the Month and the query like below:
    SELECT     Min(CAST(Month AS INT)) as NewMonth
    FROM         TableName
    Using below expression in the main dataset will display the minimum value of the month:
    =Sum(Fields!NewMonth.Value, "DataSet2")
    If you still have any problem, please feel free to ask.
    Regards
    Vicky Liu
    If you have any feedback on our support, please click
    here.
    Vicky Liu
    TechNet Community Support

  • Oracle SQL-92 Non compliance:  When will oracle support empty strings?

    Oracle is the only database on the planet that equates an empty string to a null value. For several major versions, Oracle has said "Make sure you don't rely on null and empty string equivalency because it could go away in the future." When will Oracle get with it and support this aspect of the SQL-92 standard (not to mention mathmatical logic)?

    You log enhancement requests through Metalink.
    The procedure is documented in Metalink document 166650.1 as follows:
    How to Log an Enhancement Request:
    Create a new Service Request in MetaLink.
    On the Create a SR - Brief Description screen, in the Type of problem field, select Enhancement Request.
    Important factors to remember when filling out the Enhancement Request Service Request template and creating the Service Request:
    Fully describe why the current product functionality does not meet your needs.
    Explain in detail the enhancement you would like implemented
    If possible, describe how the product can be changed to achieve the desired results.
    Describe your business expectations. Include key milestone dates and justifications as to why this request is so important and the benefits your organization stands to gain should this request be accepted.
    Once your Service Request has been created, it will be assigned to a Support Engineer who will validate your information. In some cases, your request may be a new or known product defect that the Support Engineer can either provide a fix, a workaround, or introduce to Oracle Development for resolution. In other cases, you may be presenting a valuable product enhancement that can improve Oracle product functionality. In all cases, the Support Engineer will be able to qualify your request and pass along the information to Oracle Development.
    Once the Support Engineer validates your request, and an agreed upon action plan is created, your Support Engineer will create a new Enhancement Request and provide you with an Enhancement Request tracking number. The BUG search tool on MetaLink can then be used to receive status updates.
    Please note that the Support Engineer will close the SR once the enhancement has been logged.
    Also, see document 214168.1

  • POSTING TO JSP FORMS GIVES NULL OBJECT RATHER THAN EMPTY STRING

    This post is for Dan Norris of DOE. He brought this up in a submitted tar, but it is addressed by the PDK community here.
    We arehaving problems using the standard HTTPServletRequest getParameter
    methodinside of the portal.
    The standard for this method is as follows:
    *If you usethis method to read from a text field without any text in it, you
    get an empty string. ( "" )
    *If you use it to read from a text field with text in it youwould get the
    corresponding text.
    *If you try to read from a field that doesn'texist then and only then would
    you get a Null object.
    On our portal server itis behaving differently inside of portlets.
    * If you use this method to readfrom a text field without any text in it, you
    get a Null Object
    * If you use itto read from a text field with text in it you would get the
    correspondingtext.
    * If you try to read from a field that doesn't exist you also would youget a
    Null object.
    Also, on the same server If you access a simple JSP directlywithout the it
    being a portlet, it behaves as defined by standard Javadocumentation.
    Test case:
    Create test.jsp with these contents:
    ========start test.jsp
    <%@pageimport = "oracle.portal.provider.v1.*,
    oracle.portal.provider.v1.http.*"%>
    Form to test submission of empty form field.<br>
    Text Field Value ="<%=request.getParameter("testField")%>"
    <form name="test" action="<%=
    HttpPortletRendererUtil.htmlFormActionLink(request,PortletRendererUtil.PAGE_LINK
    ) %>">
    <%=
    HttpPortletRendererUtil.htmlFormHiddenFields(request,PortletRendererUtil.PAGE_LI
    NK) %>
    <INPUT type="text" name="testField">
    <INPUT type="Submit"name="Submit">
    </form>
    ========end test.jsp
    =================startprovider.xml
    <provider class="oracle.portal.provider.v1.http.DefaultProvider"
    session="true">
    <portlet class="oracle.portal.provider.v1.http.DefaultPortlet" version="1" >
    <id>1</id>
    <name>TestPortlet</name>
    <title>Test</title>
    <description>Test</description>
    <timeout>100</timeout>
    <timeoutMsg>Test Portlet timed out.</timeoutMsg>
    <showEdit>false</showEdit>
    <showEditDefault>false</showEditDefault>
    <showPreview>false</showPreview>
    <showDetails>false</showDetails>
    <hasHelp>false</hasHelp>
    <hasAbout>false</hasAbout>
    <acceptContentTypes>
    <item>text/html</item>
    </acceptContentTypes>
    <portletRenderer class="oracle.portal.provider.v1.http.PageRenderer" >
    <appPath>/</appPath>
    <appRoot>/u01/app/oracle/product/ias1021/Apache/Apache/htdocs</appRoot>
    <renderContainer>false</renderContainer>
    <showPage>test.jsp</showPage>
    <pageParameterName>next_page</pageParameterName >
    </portletRenderer>
    </portlet>
    </provider>
    =================end provider.xml
    After you have theprovider added to the portal, login to the portal as
    portal30 and go toAdminister Tab->Display Portlet Repository and display the
    portlet.
    1.Enter "test" in the text field and submit.
    2. Returns Text Field Value ="test"
    3. Submit form leaving the text field empty.
    4. Returns Text FieldValue = "null"
    Submitting the form with the text field empty should returnvalue of "", and
    not "null".

    fyi in case anyone else ever wants to know:
    I found it... the details I was looking for were in the OC4J 9.0.2 Release Notes:
    Display of null values in JSP.
    In Oracle9iAS, a null value printed from a JSP page displays, by default, as
    the string "null." To display nothing instead, set the attribute jsp-print-null
    to false in the <web-app> element of
    global-web-app.xml or orion-web.xml.

  • ORACLE treats empty Strings as NULL, Any workaround?

    Hi,
    ORACLE treats empty Strings as NULL.
    I am writing, rather modifying Java code to make it work with both SQLServer and Oracle. Since our code is already working for SQLServer, now I have the problem in porting to Oracle wherever I have empty strings. I used to insert empty strings into coulumns in SQLServers, the same SQLs give errors in SQL Server.
    Any workaround on the DB end or in JDBC for this?
    Thanks in advance,
    Suresh
    [email protected]

    jschell wrote:
    nichele wrote:
    jwenting wrote:
    If NULL really is different in your context from an empty string you're going to have to define some sequence of characters as indicating an empty string.yes, this is what i need to implement.Sounds like a flawed design then.
    I'm wondering what's the best approach in order to avoid to change all my application isolating this behavior somewhere (wrapping the jdbc driver for instance).That doesn't make much sense to me. You should already have a database layer. You change the database layer. If you don't have a database layer then that means you have another design flaw. And in that case I would really not be the one that needs to maintain that code base.I thought a bit about the value of your answer...but i didn't find it ....sorry but i don't like who replies on forum just to say bad design/bad choice etc...if you have any kind of suggestion you are welcome, otherwise you can spend your time in doing something else instead of reply to this thread.

  • 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

  • JDBC Receiver does not convert empty string to NULL

    Hello experts,
    I am facing a problem with an INSERT statement to ORACLE DB where some of the fields are empty, for example:
    - <STATEMENT_VLP_CONT_DETAILS>
    - <TABLE_VLP_CONT_DETAILS ACTION="INSERT">
      <TABLE>VLP_CONT_DETAILS</TABLE>
    - <ACCESS>
      <VLP_HDR_ID>43</VLP_HDR_ID>
      <VLP_CONT_LINE_ID>1</VLP_CONT_LINE_ID>
      <QUANTITY>1</QUANTITY>
      <OWNER>CBHU</OWNER>
      <SERIAL_NO>3372739</SERIAL_NO>
      <CONT_ISO_CODE>2300</CONT_ISO_CODE>
      <WEIGHT>6.44</WEIGHT>
      <POL>ILASH</POL>
      <POD>FRFOS</POD>
      <FD>FRFOS</FD>
      <OPER_CODE>COS</OPER_CODE>
      <CUR_STOW_LOC>150102</CUR_STOW_LOC>
      <PRV_STOW_LOC />
      <HAZARDOUS>N</HAZARDOUS>
    In the JDBC Receiver comm channel I selected: Interpretation of Empty String Values = NULL Value.
    It seems the empty strings are not converted to NULL values as can be seen in the reflected SQL statement in RWB:
    INSERT INTO  VLP_CONT_DETAILS (VLP_HDR_ID, VLP_CONT_LINE_ID, QUANTITY, OWNER, SERIAL_NO, CONT_ISO_CODE, WEIGHT, POL, POD, FD, OPER_CODE, CUR_STOW_LOC, PRV_STOW_LOC, HAZARDOUS, EMPTY, REFER, OOG, HAZARD_IMDG, TEMP_SET, TEMP_MIN, TEMP_MAX, FRONT_OVL, REAR_OVL, RIGHT_OVW, LEFT_OVW, OVERHEIGHT, COMMODITY, BOOKING_REF, ALLOTMENT, YARD_LOC, LD_SEQ_CRANEID, LD_SEQ_NUMBER, LD_STATUS, STACKABLE, OPT_PORT_CODE1, OPT_PORT_CODE2, OPT_PORT_CODE3) VALUES (44, 1, 1, CBHU, 3372739 , 2300,  6.44, ILASH, FRFOS, FRFOS, COS,   150102,         , N, N, N, N,      ,      ,      ,      ,    ,    ,    ,    ,    ,     ,             ,    ,           ,    ,    0,    64, N,      ,      ,      )
    So, I am getting the following error:
    Could not execute statement for table/stored proc. "VLP_CONT_DETAILS" (structure "STATEMENT_VLP_CONT_DETAILS") due to java.sql.SQLException: ORA-00936: missing expression
    Help would be appreciated.

    Hi Effi,
    There is a mismatch in the field and thier value.
    Here field id 37
    VLP_HDR_ID, VLP_CONT_LINE_ID, QUANTITY, OWNER, SERIAL_NO, CONT_ISO_CODE, WEIGHT, POL, POD, FD, OPER_CODE, CUR_STOW_LOC, PRV_STOW_LOC, HAZARDOUS, EMPTY, REFER, OOG, HAZARD_IMDG, TEMP_SET, TEMP_MIN, TEMP_MAX, FRONT_OVL, REAR_OVL, RIGHT_OVW, LEFT_OVW, OVERHEIGHT, COMMODITY, BOOKING_REF, ALLOTMENT, YARD_LOC, LD_SEQ_CRANEID, LD_SEQ_NUMBER, LD_STATUS, STACKABLE, OPT_PORT_CODE1, OPT_PORT_CODE2, OPT_PORT_CODE3
    And value is 35
    44, 1, 1, CBHU, 3372739 , 2300, 6.44, ILASH, FRFOS, FRFOS, COS, 150102, , N, N, N, N, , , , , , , , , , , , , , , 0, 64, N, , ,
    Give empty values for nuil fields so that they can be made NULL by jdbc adapter
    Regards
    Suraj

  • NULL vs. Empty String

    I am new to ORACLE, moving over from MS SQL Server. Is it true that you cannot enter an empty string into a NOT NULL VARCHAR2?
    I am trying to convert data from an existing DB and I NEED to be able to have an empty string as much of the code base is using this to validate data (vs. a NULL). Is there any solution at all for this problem? I really do not want to keep my existing DB running but there is too much time involved converting code.
    Thanks, In Advance

    Bryna,
    In Oracle database, Oracle treats NULL and empty string
    column the same. Therefore, you cannot insert an empty string into a NOT NULL column.
    In OracleDataReader, if you want to find out if the column contains the NULL values, use the OracleDataReader.IsDBNull() function.
    Thanks
    Martha

Maybe you are looking for