Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003

    Unanswered: 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.

  2. #2
    Join Date
    Sep 2003
    The extremely Royal borough of Kensington, London
    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.

  3. #3
    Join Date
    Oct 2003

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts