Skip to Content

Assigning Empty Strings to String Field Throws OpenSQLException

Hi there,

I have defined a DB table with different fields, one of these is field COMMENT, type set to string, Dim to 1024, that means real type Varchar (when controlling via SQL Studio; within the DDIC Project in Netweaver Developer Studio, it says LONGVARCHAR for being bigger than 1000 chars), code is UNICODE, Not Null not set.

When I insert a row and there is no comment, an empty string is set for COMMENT. But this throws a com.sap.sql.log.OpenSQLException: Cannot assign an empty string to host variable

Why this?

When I control the string before and set the field to null instead of the empty string, it "works". (But that's definitely ugly).

Thanks in advance

Detlev

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2004 at 09:15 AM

    Hi Detlev,

    For portability reasons Open SQL does not allow for storing empty strings in VARCHAR, LONGVARCHAR, or CLOB columns.

    Best regards,

    Zornitsa

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Zornitsa,

      ok, so far, but I have some problems to understand why the conversion from an empty string to NULL ist not done by OpenSQL. If I have no possibility to store an empty string as an empty string, why not converting it within OpenSQL? If this is documented, everybody knows this and could react if he/she wants another reaction on empty strings, but the normal way will be to store empty strings as NULL, if I cannot store them as empty strings. With the situation as it is now, one million OpenSQL developers 😉 are converting empty strings to NULL. Hm, not so nice...

      Best regards

      Detlev

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.