Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Set value of empty field to NULL
Message
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01520257
Message ID:
01520265
Views:
36
>>>>Hi,
>>>>
>>>>I am looking for a suggestion on handling the following situation.
>>>>
>>>>Foreign key constraint requires that the application either set some value to a foreign key or a NULL. When user clears an entry in one of these fields (in VFP application) I need to set the value to NULL before updating SQL Server table. This works but requires some maintenance (e.g. meta table of fields that need to be NULLed in case the value is empty). I am wondering, is there anything can be done in the SQL Server so that the Empty-2-Null would be done automatically by SQL Server?
>>>>
>>>>TIA.
>>>
>>>What exactly you're using in VFP - CursorAdapter? If yes, I think there is a property to convert empty to null.
>>>
>>>In SQL Server you can achieve it with INSTEAD OF triggers, which seem to be an overkill for the task.
>>
>>Yes, I use CursorAdapter. Is the property "convert empty to null" a property of VFP CA?
>>
>>UPDATE. I looked through properties of CA and don't such a property. And it would not even make sense, if I think about it, since not all fields have to be converted from empty to null.
>
>I remember having something like this. However, another simple way will be to use BeforeInsertCmd command

I am thinking about using the method of leaving a row in the parent table with empty value in the unique field. I started a different thread on this topic. This way, with the empty row, I won't have to worry about these issues and deal with NULLs in the UI (VFP). I can simply "hide" this row from the user so they won't know that such row exists.
"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