Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to add a column placeholder allow NULL
Message
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01536981
Message ID:
01536999
Views:
29
>>>>What is wrong with CAST(null as int)? Why the Coalesce is necessary?
>>>
>>>Because he wanted to get 0 as the field's value, I assume.
>>
>>I think the approach Hugo suggested may work. Since I am using this column as a placeholder the field value will be set according to the business logic of the program (I know that me and logic do not go together well <g>). Most of the values will be set to 0 or 1. But there could be a case where the value will be NULL and this is why I want to allow NULLs.
>>
>>Thank you, Hugo.
>
>If you want to create a placeholder with NULL value, then simply CAST (NULL as INT) and it will work in both VFP and SQL Server. But if you want to create 0 as a value but also allow NULLs to be entered, then use the approach I suggested.

You see, when I initially create this cursor I get NO records. The cursor is empty. Then the code of the program, based on the user selection, sets the value. So the simple case of CAST(null as int) should work. I never even thought that such syntax will work. I thought that for CAST to work the value has to be no-null. But I suppose I misunderestimated (thank you GWB <g>) the capabilities of the VFP and SQL Server. I am glad you suggested the Coalesce function because this will force me to learn it better.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform