Re: Update entire column with new date values - Mailing list pgsql-general

From Richard Huxton
Subject Re: Update entire column with new date values
Date
Msg-id 44C8DF94.1090101@archonet.com
Whole thread Raw
In response to Update entire column with new date values  ("Weiss, Kevin" <kevin.weiss@selkirkinc.com>)
List pgsql-general
Weiss, Kevin wrote:
> I need to update the date for each file (the "date" & "filename"
> columns). However, the updated values for date are not the same for each
> file (due to when the files were last modified). I can import the new
> date values from a text file containing the date and filename.
>
> What sort of "UPDATE" command do I use in this case? Essentially, I'm
> trying to do something like:
>
> UPDATE docs SET date = '{$input_date}'
>     FROM ('C:/Temp/docupdate.txt')
>     WHERE filename = '{$input_filename}';

You'll want to gather your updates into a table and then use the
non-standard FROM clause to do pretty much what you're trying to here.

http://www.postgresql.org/docs/8.1/static/sql-update.html

UPDATE docs SET date = ???
FROM newvals
WHERE docs.filename=newvals.filename

Failing that look at a subselect in your SET clause.

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: "Jasbinder Bali"
Date:
Subject: Re: Permissions to connect to postgres database
Next
From: Richard Huxton
Date:
Subject: Re: Permissions to connect to postgres database