0

Here is my sample statement:

conn.cursor.execute("insert into Employee(name, manager) values(?,?)", ('rahul',''))

I'm using Sybase as database. If I execute the statement using a database client:

insert into Employee(name, manager) values('rahul','')

then, empty values are inserted for manager column, which is desired.

But when I execute the prepared statement, NULL values are inserted into the database.

How this is happening? And how to fix this issue? Thank you!

Rahul Raj
  • 3,197
  • 5
  • 35
  • 55

1 Answers1

0

When you execute the INSERT statement, the database server inserts a NULL value into any column for which you provide no value, as well as for all columns that have no default values. You can set the default value for that column which might fix this issue.

Edit: Instead of passing '' try passing ' ', it might fix the issue. I think the database check the length of the string and when the length is 0 it inserts a Null value.