dbTalk Databases Forums  

the column in Update

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss the column in Update in the comp.databases.postgresql.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
John Fabiani
 
Posts: n/a

Default the column in Update - 11-09-2004 , 08:33 PM






From the 7.4 docs:
A column can be referenced in the form

correlation.columnname

correlation is the name of a table (possibly qualified with a schema name),or
an alias for a table defined by means of a FROM clause, or one of the key
words NEW or OLD. (NEW and OLD can only appear in rewrite rules, while other
correlation names can be used in any SQL statement.) The correlation name and
separating dot may be omitted if the column name is unique across all the
tables being used in the current query. (See also Chapter 7.)

So then why does this not work:
Update tablename set tablename.columnName = 'somedata' where .....

John

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


Reply With Quote
  #2  
Old   
Martijn van Oosterhout
 
Posts: n/a

Default Re: the column in Update - 11-10-2004 , 05:31 AM






Probably because the bit after the SET is a "column-name" not a
reference to a column. There's no point qualifying it in any way since
the tablename is given as part of the UPDATE statement.

On Tue, Nov 09, 2004 at 06:33:55PM -0800, John Fabiani wrote:
Quote:
From the 7.4 docs:
A column can be referenced in the form

correlation.columnname

correlation is the name of a table (possibly qualified with a schema name), or
an alias for a table defined by means of a FROM clause, or one of the key
words NEW or OLD. (NEW and OLD can only appear in rewrite rules, while other
correlation names can be used in any SQL statement.) The correlation nameand
separating dot may be omitted if the column name is unique across all the
tables being used in the current query. (See also Chapter 7.)

So then why does this not work:
Update tablename set tablename.columnName = 'somedata' where .....

John

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
--
Martijn van Oosterhout <kleptog (AT) svana (DOT) org> http://svana.org/kleptog/
Quote:
Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
tool for doing 5% of the work and then sitting around waiting for someone
else to do the other 95% so you can sue them.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFBkfwlY5Twig3Ge+YRAnifAKCrgwGs9XoyL3dR4FAePG WAONK21QCgtT1x
s5bhBhcX3bDzP35VXFRljOI=
=hd0W
-----END PGP SIGNATURE-----



Reply With Quote
  #3  
Old   
John Fabiani
 
Posts: n/a

Default Re: the column in Update - 11-10-2004 , 05:27 PM



Thanks but in the doc's it uses the term 'columnname'. The real issue is the
tablename.columnname is supported in MySQL and I'm trying to support Postgres
and MySQL with a single code routine.
John
On Wednesday 10 November 2004 03:31, Martijn van Oosterhout wrote:
Quote:
Probably because the bit after the SET is a "column-name" not a
reference to a column. There's no point qualifying it in any way since
the tablename is given as part of the UPDATE statement.

On Tue, Nov 09, 2004 at 06:33:55PM -0800, John Fabiani wrote:
From the 7.4 docs:
A column can be referenced in the form

correlation.columnname

correlation is the name of a table (possibly qualified with a schema
name), or an alias for a table defined by means of a FROM clause, or one
of the key words NEW or OLD. (NEW and OLD can only appear in rewrite
rules, while other correlation names can be used in any SQL statement.)
The correlation name and separating dot may be omitted if the column name
is unique across all the tables being used in the current query. (See
also Chapter 7.)

So then why does this not work:
Update tablename set tablename.columnName = 'somedata' where .....

John

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



Reply With Quote
  #4  
Old   
Peter Eisentraut
 
Posts: n/a

Default Re: the column in Update - 11-10-2004 , 05:52 PM



John Fabiani wrote:
Quote:
Thanks but in the doc's it uses the term 'columnname'. The real
issue is the tablename.columnname is supported in MySQL and I'm
trying to support Postgres and MySQL with a single code routine.
Surely MySQL would also support writing a column name without a table
name?

--
Peter Eisentraut
http://developer.postgresql.org/~petere/


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html



Reply With Quote
  #5  
Old   
Tom Lane
 
Posts: n/a

Default Re: the column in Update - 11-10-2004 , 06:23 PM



John Fabiani <jfabiani (AT) yolo (DOT) com> writes:
Quote:
Thanks but in the doc's it uses the term 'columnname'. The real issue is the
tablename.columnname is supported in MySQL and I'm trying to support Postgres
and MySQL with a single code routine.
If you want portable code, I suggest conforming to the SQL-standard
syntax. The table name is disallowed there according to the spec.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match



Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.