Ask a Question
Advertise on boostr.in
Organizational Research By
Surprising Reserch Topic
oracle considers empty strings to be null while sql server does not how is thi
oracle considers empty strings to be null while sql server does not how is thi ¬†using -'sql-server,oracle'
I have to write a component that re-creates SQL Server tables (structure and data) in an Oracle database. ¬†This component also has to take new data entered into the Oracle database and copy it back into SQL Server.
Translating the data types from SQL Server to Oracle is not a problem. ¬†However, a critical difference between Oracle and SQL Server is causing a major headache. ¬†SQL Server considers a blank string ("") to be different from a NULL value, so a char column can be defined as NOT NULL and yet still include blank strings in the data.
Oracle considers a blank string to be the same as a NULL value, so if a char column is defined as NOT NULL, you cannot insert a blank string. ¬†This is causing my component to break whenever a NOT NULL char column contains a blank string in the original SQL Server data.
So far my solution has been to not use NOT NULL in any of my mirror Oracle table definitions, but I need a more robust solution. ¬†This has to be a code solution, so the answer can't be "use so-and-so's SQL2Oracle product".
How would you solve this problem?
Edit: ¬†here is the only solution I've come up with so far, and it may help to illustrate the problem. ¬†Because Oracle doesn't allow "" in a NOT NULL column, my component could intercept any such value coming from SQL Server and replace it with "@" (just for example).
When I add a new record to my Oracle table, my code has to write "@" if I really want to insert a "", and when my code copies the new row back to SQL Server, it has to intercept the "@" and instead write "".
I'm hoping there's a more elegant way.
Edit 2: ¬†Is it possible that there's a simpler solution, like some setting in Oracle that gets it to treat blank strings the same as all the other major database? ¬†And would this setting also be available in Oracle Lite?
Oct 7, 2015
to add a comment.
Related Hot Questions
Government Jobs Opening