cancel
Showing results for 
Search instead for 
Did you mean: 

Assigning Empty Strings to String Field Throws OpenSQLException

detlev_beutner
Active Contributor
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Detlev,

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

Best regards,

Zornitsa

detlev_beutner
Active Contributor
0 Kudos

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