Re: [GENERAL] Need to update all entries of one table based on an earlier backup

2008-06-20 Thread Thomas Pundt
On Freitag, 20. Juni 2008, Gregory Williamson wrote:
| For reasons best left unmentioned, I need to update entries in a table from
| a backup; I need to do all entries.
|
| For reasons eluding my sleep deprived eyes this fails in every variation I
| can think of:
|
| update foo set foo.foo_name2=foo_old.foo_name2 where foo.foo_id =
| foo_old.foo_id; ERROR:  missing FROM-clause entry for table "foo_old"

Does 

update foo 
   set foo.foo_name2 = foo_old.foo_name2 
  from foo_old
 where foo.foo_id = foo_old.foo_id;

work for you?

| Could someone please hit me with a clue-stick ? This is crucial and yet I
| am stumbling over something. Since I am not updating foo_old I am baffled
| as to what this messsage really means. I've tried "where foo_old.foo_id =
| foo.foo_id ... same message.

Ciao,
Thomas

-- 
Thomas Pundt <[EMAIL PROTECTED]>  http://rp-online.de/ 

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Need to update all entries of one table based on an earlier backup

2008-06-20 Thread Gregory Williamson
Thomas Pundt wrote:
> 
> On Freitag, 20. Juni 2008, Gregory Williamson wrote:
<...snip...>
> Does 
> 
> update foo 
>set foo.foo_name2 = foo_old.foo_name2 
>   from foo_old
>  where foo.foo_id = foo_old.foo_id;
> 
> work for you?

Thanks to all for pointing out the FROM clause.!

"UPDATE foo set foo_name2 = foo_old.foo_name2 FROM foo_old WHERE foo.foo_id = 
foo_old.foo_id;" did the trick.  

For some reason I keep forgetting that bit. Especially when under stress in the 
wee hours of the morn. Back to sleep ... ZZZ

And thanks again !

GSW


Re: [GENERAL] Need to update all entries of one table based on an earlier backup

2008-06-20 Thread Markus Wollny
Hi!
 
You're missing a table declaration for the table foo_old. You might try this:
 
update foo set foo.foo_name2= (SELECT foo_old.foo_name2 FROM foo_old where 
foo.foo_id = foo_old.foo_id);
 
Kind regards
 
  Markus




Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Gregory 
Williamson
Gesendet: Freitag, 20. Juni 2008 12:30
An: pgsql-general@postgresql.org
Betreff: [GENERAL] Need to update all entries of one table based on an 
earlier backup



For reasons best left unmentioned, I need to update entries in a table 
from a backup; I need to do all entries.

For reasons eluding my sleep deprived eyes this fails in every 
variation I can think of:

update foo set foo.foo_name2=foo_old.foo_name2 where foo.foo_id = 
foo_old.foo_id;
ERROR:  missing FROM-clause entry for table "foo_old"

Could someone please hit me with a clue-stick ? This is crucial and yet 
I am stumbling over something. Since I am not updating foo_old I am baffled as 
to what this messsage really means. I've tried "where foo_old.foo_id = 
foo.foo_id ... same message.

TIA,

Greg Williamson
Senior DBA
DigitalGlobe

Confidentiality Notice: This e-mail message, including any attachments, 
is for the sole use of the intended recipient(s) and may contain confidential 
and privileged information and must be protected in accordance with those 
provisions. Any unauthorized review, use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please contact the sender by 
reply e-mail and destroy all copies of the original message.

(My corporate masters made me say this.)





Computec Media AG
Sitz der Gesellschaft und Registergericht: Fürth (HRB 8818)
Vorstandsmitglieder: Johannes S. Gözalan (Vorsitzender) und Rainer Rosenbusch
Vorsitzender des Aufsichtsrates: Jürg Marquard 
Umsatzsteuer-Identifikationsnummer: DE 812 575 276




[GENERAL] Need to update all entries of one table based on an earlier backup

2008-06-20 Thread Gregory Williamson
For reasons best left unmentioned, I need to update entries in a table from a 
backup; I need to do all entries.

For reasons eluding my sleep deprived eyes this fails in every variation I can 
think of:

update foo set foo.foo_name2=foo_old.foo_name2 where foo.foo_id = 
foo_old.foo_id;
ERROR:  missing FROM-clause entry for table "foo_old"

Could someone please hit me with a clue-stick ? This is crucial and yet I am 
stumbling over something. Since I am not updating foo_old I am baffled as to 
what this messsage really means. I've tried "where foo_old.foo_id = foo.foo_id 
... same message.

TIA,

Greg Williamson
Senior DBA
DigitalGlobe

Confidentiality Notice: This e-mail message, including any attachments, is for 
the sole use of the intended recipient(s) and may contain confidential and 
privileged information and must be protected in accordance with those 
provisions. Any unauthorized review, use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please contact the sender by 
reply e-mail and destroy all copies of the original message.

(My corporate masters made me say this.)