简体   繁体   中英

Why oracle DB does not update the fileds

I do not know what is wrong with this query but it does not give any error and does not update the row. ENDDATETIME field datatype is TIMESTAMP.

UPDATE TEST_BANK set STATUS = 'RECEIVED', ENDDATETIME = '16-JUN-15 11.21.06.000000000' WHERE ENDDATETIME = null ;

在此处输入图片说明

见附件截图

I believe in Oracle the syntax for checking for null is as following

 WHERE ENDDATETIME IS NULL

instead of the

 WHERE ENDDATETIME = NULL

你可以试试这个

UPDATE TEST_BANK set STATUS = 'RECEIVED', ENDDATETIME = '16-JUN-15 11.21.06.000' WHERE ENDDATETIME is null ;

Your ENDDATETIME format is wrong, hence its not selected.

Just copy paste the column value, and paste it in where clause ..it will work

Are you able to get the result

Select * from TEST_BANK WHERE ENDDATETIME = null ;

Use IS NULL instead of = null

You can't compare NULL values. You'll need the "IS" operator.

UPDATE TEST_BANK 
   SET STATUS = 'RECEIVED', 
       ENDDATETIME = '16-JUN-15 11.21.06.000000000' 
 WHERE ENDDATETIME IS NULL ;

To explain this: Assume Mr. Little and Mr. Large. You don't know how tall they are (size is null). Now can you positively state that they are of the same size? If not, they won't be "selected" when compared. Hence you need a comparion function to test if the value is unknown, which is what the "IS NULL" does.

Operator is always applied on data while NULL is predicate in oracle. So it won't be worked with operator.

When ever you want to deal with NULL always use IS NULL or IS NOT NULL.

Nulls with Comparison Conditions

To test for nulls, use only the comparison conditions IS NULL and IS NOT NULL. If you use any other condition with nulls and the result depends on the value of the null, then the result is UNKNOWN. Because null represents a lack of data, a null cannot be equal or unequal to any value or to another null. However, Oracle considers two nulls to be equal when evaluating a DECODE function. Please refer to DECODE for syntax and additional information.

Oracle also considers two nulls to be equal if they appear in compound keys. That is, Oracle considers identical two compound keys containing nulls if all the non-null components of the keys are equal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM