If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > SQL Update problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-26-03, 00:22
AAichael AAichael is offline
Registered User
 
Join Date: Nov 2003
Posts: 1
SQL Update problem

Is there any sort of operator that can be used with update besides '=' ?

for example,

UPDATE table SET name ? 'name variable'



The reason i want to know is, im writing a program that updates many attributes at once. However, if a given attribute is null, and it is being updated to a null, the update command fails.
Reply With Quote
  #2 (permalink)  
Old 11-26-03, 00:30
r123456 r123456 is offline
Registered User
 
Join Date: Sep 2003
Location: The extremely Royal borough of Kensington, London
Posts: 778
SQL> update sample
2 set a=null, b=null, c='NEW';

This works for me. Obviously if your table has NOT NULL as a constraint then it would fail.
__________________
Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.
Reply With Quote
  #3 (permalink)  
Old 11-26-03, 02:35
cvandemaele cvandemaele is offline
Registered User
 
Join Date: Oct 2003
Location: Switzerland
Posts: 140
Re: SQL Update problem

=>Is there any sort of operator that can be used with update besides '=' ?

1. No, there is not. Within the UPDATE TABLE SET COLUMN = VALUE statement, the '=' is not a comparison operator, but an assignment operator. By definition, a SET instruction can only work with assignment operators.

2. What you can do to avoid assigning null values is to use ISNULL(mssql), NVL (Oracle), COALESCE (both).

3. Before trying to circumvent a problem (in your case a failed update), make sure you understand why the problem occurs.

Good luck.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On