Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Instead of Update trigger
Message
 
 
À
08/08/2011 18:35:46
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, États-Unis
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
01520382
Message ID:
01520467
Vues:
27
Thank you, James. This is what I was doing and I thought I could improve my application (read, reduce maintenance) if I delegate stuff/code to the SQL Server. But it turns out that it is not to be.


>Dmitry,
>
>It seems to me that you are doing an awful lot of work just to keep from using nulls. Use RI in your database then in your CAs check the columns that need to be null and and set the empty values to null before you save the row. JMHO.
>
>
>>Let me give you an example. User creates a purchase order. One of the fields of the purchase order is a cost center (an account) to which P.O. could be optionally charged. Each cost center is a unique field in the Cost Center table. The P.O. table has Cost Center foreign key. This Cost Center is a char field. If user enters a Cost Center in the P.O., everything is well. But when user clears (removes) entry from the P.O. table (because he/she decide that they do not want to charge the P.O. to a cost center), I want the Cost Center in the P.O. table to be empty string (not NULL).
>>Also when user deletes a Cost Center from the Cost Center table, after a warning, the foreign key in all P.O.s where the deleted Cost Center was used should be either set to NULL or empty string. I need/prefer that it is set to empty string. This is why I needed to have record in the Cost Center table with empty value in the Cost Center field.
>>
>>Does it all make sense?
"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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform