Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Function empty() and null value
Message
De
26/06/2011 20:30:34
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01516146
Message ID:
01516151
Vues:
53
>>>Hi,
>>>
>>>When using SQL Server and allowing NULL in empty dates I came across a small issue where EMPTY( date_field) returns .F. when the entry in date_field is NULL. And this of course breaks a lot of code where the program relied on the date field being empty. I am thinking of creating a simple function like this:
>>>
>>>Function MyEmpty
>>>lparameter tDate
>>>if empty( tDate) or isnull( tDate)
>>>   return .T.
>>>else
>>>  return .F.
>>>endif 
>>>
>>>
>>>And replace everywhere in the program where I use
>>>
>>>if EMPTY( date_field ) 
>>>
>>>with
>>>
>>>if MyEmpty( date_field )
>>>
>>>
>>>Can anybody see a potential problem with the above approach? TIA.
>>
>>IF EMPTY(nvl(datefield,{})).....

>
>I think your approach is probably better. Except a little more characters to type when making changes <g>. Thank you.

You can always pass the var to a function and check it there - you could set it to an empty date if it's null or check it for a valid date within a range if it's not null, etc....


You're welcome ;o)
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform