¿Can I select what kind of answer I´m going to obtain from my database when is a NULL there ?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Friday, August 31, 2001 03:24 AM


When I get data from my database, depending on the enviroment sometimes I obtain NULL from database as String = NULL and others as String = "".

¿Is there a way of select what kind of answer i´ll obtain in my code?

Please reply to fvillasenor@wanadoo.es

Thanks in advance.

Fran.

Re: ¿Can I select what kind of answer I´m going to obtain from my database when is a NULL there ?

Posted By:   Anonymous  
Posted On:   Sunday, September 2, 2001 06:50 PM

Nulls can often cause situations the programmer doesn't expect or isn't prepared for. Unless there is a specific reason to allow them, disallow nulls in your database. After that you should only have empty strings to check for ( depending on any differing default values. )

Re: ¿Can I select what kind of answer I´m going to obtain from my database when is a NULL there ?

Posted By:   Bozidar_Dangubic  
Posted On:   Friday, August 31, 2001 06:22 AM

depends what is in the database. if database field has a NULL then you are going to get NULL back. if it has an empty string you will get an empty string. it is a simple as that. if you need to have all char fields in the database that contain empty strings be NULL, you can run a simple query to the database to enforce this. but you also need to make sure that in your design when you are doing an insert you insert a null instead of empty string. now, some drivers are funky about that. informix jdbc drivers as of 2.1 version required a vendor-specific cast to insert a null in the database through a jdbc call making your code non-portable when RDBMS changes. so that is another thing you need to worry about.
About | Sitemap | Contact