473,767 Members | 7,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Updates with NULL

Hello All,

I was just updating a table in oracle9.2 by hand and bumped into this.

Following seems to be the valid syntax in oracle.

Update foo set somefield=NULL where somefield >9;

Now I am not sure having something equalled with NULL is a good thig logically.
I would say

Update foo set somefield [to] NULL where somefield >9;

sounds much better. Postgresql uses =default expression which is fine.

Is Oracle behaviour correct?
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 11 '05 #1
5 16286

On Mon, 15 Sep 2003, Shridhar Daithankar wrote:
I was just updating a table in oracle9.2 by hand and bumped into this.

Following seems to be the valid syntax in oracle.

Update foo set somefield=NULL where somefield >9;

Now I am not sure having something equalled with NULL is a good thig logically.
I would say

Update foo set somefield [to] NULL where somefield >9;

sounds much better. Postgresql uses =default expression which is fine.

Is Oracle behaviour correct?


Yes (and we also allow update foo set somefield=NULL) .

<set clause list> ::=
<set clause> [ { <comma> <set clause> }... ]

<set clause> ::=
<object column> <equals operator> <update source>

<update source> ::=
<value expression>
| <null specification>
| DEFAULT

<object column> ::= <column name>

and null specification is:

<null specification> ::=
NULL
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly

Nov 11 '05 #2
"Shridhar Daithankar" <sh************ *****@persisten t.co.in> writes:
Following seems to be the valid syntax in oracle. Update foo set somefield=NULL where somefield >9;


AFAIK that's valid syntax in Postgres and the SQL standard, too.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 11 '05 #3
On Mon, 15 Sep 2003 19:34:48 +0530, "Shridhar Daithankar"
<sh************ *****@persisten t.co.in> wrote:
Update foo set somefield=NULL where somefield >9;

Now I am not sure having something equalled with NULL is a good thig logically.


It doesn't matter whether I agree. The standard does not. SQL92 says

<set clause> ::=
<object column> <equals operator> <update source>

<equals operator> ::= =

<update source> ::=
<value expression>
| <null specification>
| DEFAULT

<null specification> ::=
NULL

SQL99 is much more verbose and difficult to read, but it is very clear
that the assignment operator in a set clause has to be "=".

Servus
Manfred

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 11 '05 #4
On 15 Sep 2003 at 11:17, Tom Lane wrote:
"Shridhar Daithankar" <sh************ *****@persisten t.co.in> writes:
Following seems to be the valid syntax in oracle.

Update foo set somefield=NULL where somefield >9;


AFAIK that's valid syntax in Postgres and the SQL standard, too.


I got confused between equality operator and assignment operator. Equalling
NULL is wrong, assigning it is not.

I should have had more rest after my fever..:-(

Bye
Shridhar

--
Fifth Law of Procrastination : Procrastination avoids boredom; one never has the
feeling that there is nothing important to do.
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 11 '05 #5
It's just an assignment statement, how ELSE would you assign a value,
even a NULL, to a field?

Manfred Koizar wrote:
On Mon, 15 Sep 2003 19:34:48 +0530, "Shridhar Daithankar"
<sh*********** ******@persiste nt.co.in> wrote:

Update foo set somefield=NULL where somefield >9;

Now I am not sure having something equalled with NULL is a good thig logically.


It doesn't matter whether I agree. The standard does not. SQL92 says

<set clause> ::=
<object column> <equals operator> <update source>

<equals operator> ::= =

<update source> ::=
<value expression>
| <null specification>
| DEFAULT

<null specification> ::=
NULL

SQL99 is much more verbose and difficult to read, but it is very clear
that the assignment operator in a set clause has to be "=".

Servus
Manfred

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 11 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4263
by: Walt | last post by:
It's easy to make a field required for inserts, just set it to not null and don't give it a default. But how does one make a field required for updates? For instance, we have a table with a field that keeps track of which application last updated the table MYTABLE ------ ID PK
6
9999
by: Steven An | last post by:
Howdy, I need to write an update query with multiple aggregate functions. Here is an example: UPDATE t SET t.a = ( select avg(f.q) from dbo.foo f where f.p = t.y ), t.b = ( select sum(f.q) from dbo.foo f where f.p = t.y ) FROM dbo.test t
0
1840
by: Manoj Sharma | last post by:
I am performance testing some batch processing engines. These are written in ..NET and SQL Server and are typically concerned with generating XML files out of data retrieved from the database. I have two machines one running IIS Server and the other SQL Server. Problem Description: One of the engines is failing with the following exception:
4
1817
by: DXJas | last post by:
I have a form that calls a stored procedure to perform updates to a table in sqlserver. When I have a dropdown with a list item value of nothing, the formview control passes up the wrong value to the stored procedure. In some cases this will be the primary key for my record and in a different dropdown on the same page I may get the "*" symbol. I'm not sure what the problem is though. NOte: I did have an issue setting up the formview...
4
1713
by: T.H.N. | last post by:
I'm trying to work out a database design to make it quicker for my client program to read and display updates to the data set. Currently it reads in the entire data set again after each change, which was acceptable when the data set was small but now it's large enough to start causing noticable delays. I've come up with a possible solution but am looking for others' input on its suitability to the problem. Here is the DDL for one of the...
8
12012
by: shorti | last post by:
DB2 V8.2 on AIX I am looking for an efficient way to update several columns in a table that will have a default change. The problem is the table is large (million records) and there are 1 to 4 columns that might need to be changed per record. I wanted to avoid looping through the table 4 times in order to change them. Here is an example. Basically, the four columns in question were originally defaulted to NULL. Due to changes...
1
5101
rickbray66
by: rickbray66 | last post by:
DB2 Express for Windows: DB2 v9.1.200.166 Hello. I've recently started working with DB2. I'm in the process of migrating a DDL from MySQL over to DB2. Consider the following snipet: CREATE TABLE `book_unit` ( `book_unit_id` varchar(32) NOT NULL default '', `last_updated` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1
1557
by: db2user99 | last post by:
Hi All, Can anyone please help me figure out the error with these stored Procedures.I am trying to perform large updates.The Updates are being performed but it goes into an infinite loop. CREATE PROCEDURE SAMPLE.SPROC (IN p_tablename varchar (50), IN p_IDNO integer) BEGIN DECLARE SQLCODE INTEGER ; DECLARE txt varchar (10000); DECLARE stmt varchar (10000);
4
1218
dbrewerton
by: dbrewerton | last post by:
Ok, I'm using code-behind with a MySQL DB to update two tables. It updates the addressbook table fine but the device table won't update. I know its probably some stupid syntax error but I am not seeing it. To be sure I have the right variables set, I am using labels for the IDs. The ID numbers are correct. Can someone help? Thanks. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI;...
0
10014
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9960
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9841
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7384
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6656
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5280
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5425
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3931
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3534
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.