on 12-30-2005 9:48 AM
Hi,
I am migrating a J2ee project to SAP netweaver server. As a part of the project, some time i need to store empty string, null values or spaces to the databse tables. But when ever I am trying to insert a record in to the DB with some field values as empty strings (""), I am getting a SQL Exception as given below,
"<b>com.sap.sql.log.OpenSQLException: Cannot assign an empty string to host variable 3</b>"
When i tried to insert a record with empty string as some field values directly in to the table using SQL(insert into.. )statement, I am able to insert the record.
I need to pass the empty string based on the application requirement
Your help and suggestions solicited in this regard.
Thankyou,
Sudheesh K S....
Hi Sudheesh,
Try inserting into the DB by giving specific column names in the SQL query. This will automatically insert a blank in the DB field which you are not specified in the Query.
Hope it helps.
Regards,
Maheswaran.B
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello sir,
But I am using Entity bean with CMP.
As i stated before I am facing the problem only when i am calling the bean and creating a new record from the application. When i tried to insert the record directly using SQL, the query executed successfully...
Sir, Any idea regarding this?
Regards,
Sudheesh
Hi sudheesh,
The problem is definately because of the definition of data types used for the fields.
Please check up what are the constraints you have put on the various characters.
There is a link "creating data types in Java dictionary"
http://help.sap.com/saphelp_nw04s/helpdata/en/39/5b033eec2bc452e10000000a114084/frameset.htm
Check if the above link helps
If you are defining the datatype as string,there is something interesting.
String
VARCHAR (N)
Varying length character strings with a maximum length of N characters
1 - 1000 Characters
Yes
LONGVARCHAR(N)
Varying length character strings with a maximum length of N characters
1001 - 1333 Characters
No
CLOB
Varying length character strings of virtually unlimited size
357.913.941 Characters
No
I found this sepcification in the link "Open sql data types for Java Dictionary"
So as you can see for portability of jdbc data,the length of string should atleast be '1'.
Regards,
Harish
(Please award points for helpful answers)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Is this problem occuring only for column 3 or any other column.
Can you tell us how you have defined the table in the dictionary.
Regards,
Harish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.