Re: [GENERAL] Updating column on row update

2009-11-22 Thread silly8888
> MySQL had the following syntax available: > `updated_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update > CURRENT_TIMESTAMP I wonder supporting this syntax would speed things up a little bit. Here's a simple benchmark about the situation we are discussing here: There are 2 tables:

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Tom Lane
Craig Ringer writes: > I do think this comes up often enough that a built-in trigger "update > named column with result of expression on insert" trigger might be > desirable. There's something of the sort in contrib already, I believe, though it's so old it still uses abstime :-( > So might "CRE

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Thom Brown
2009/11/22 Craig Ringer > On 23/11/2009 4:15 AM, Scott Marlowe wrote: > > On Sun, Nov 22, 2009 at 12:50 PM, Thom Brown > wrote: > >> Hi, > >> This should be simple, but for some reason I'm not quite sure what the > >> solution is. I want to be able to update the value of a column for rows > >>

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Craig Ringer
On 23/11/2009 4:15 AM, Scott Marlowe wrote: > On Sun, Nov 22, 2009 at 12:50 PM, Thom Brown wrote: >> Hi, >> This should be simple, but for some reason I'm not quite sure what the >> solution is. I want to be able to update the value of a column for rows >> that have been updated. More specifical

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Thom Brown
2009/11/22 Christophe Pettus > David Fetter and Andreas Scherbaum also have solutions for this in > reployment scripts: > > > http://people.planetpostgresql.org/dfetter/index.php?/archives/23-CREATE-OR-REPLACE-LANGUAGE.html > > http://andreas.scherbaum.la/blog/archives/346-create-language-if-not-

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Christophe Pettus
David Fetter and Andreas Scherbaum also have solutions for this in reployment scripts: http://people.planetpostgresql.org/dfetter/index.php?/archives/23-CREATE-OR-REPLACE-LANGUAGE.html http://andreas.scherbaum.la/blog/archives/346-create-language-if-not-exist.html -- -- Christ

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Adrian Klaver
On Sunday 22 November 2009 1:10:36 pm Thom Brown wrote: > 2009/11/22 Scott Marlowe > > > > Thanks Scott. It's a shame a function has to be used because it then > > > has the dependency of plpgsql being loaded. I'm attempting to write a > > > > database > > > > > schema to accompany a PostgreSQL

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Thom Brown
2009/11/22 Scott Marlowe > > Thanks Scott. It's a shame a function has to be used because it then has > > the dependency of plpgsql being loaded. I'm attempting to write a > database > > schema to accompany a PostgreSQL driver for a popular CMS, but I guess I > > could get it to load plpgsql in

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Scott Marlowe
On Sun, Nov 22, 2009 at 1:32 PM, Thom Brown wrote: > Thanks Scott.  It's a shame a function has to be used because it then has > the dependency of plpgsql being loaded.  I'm attempting to write a database > schema to accompany a PostgreSQL driver for a popular CMS, but I guess I > could get it to

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Scott Marlowe
On Sun, Nov 22, 2009 at 1:32 PM, Thom Brown wrote: > 2009/11/22 Scott Marlowe >> >> On Sun, Nov 22, 2009 at 12:50 PM, Thom Brown wrote: >> > Hi, >> > This should be simple, but for some reason I'm not quite sure what the >> > solution is.  I want to be able to update the value of a column for ro

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Thom Brown
2009/11/22 Scott Marlowe > On Sun, Nov 22, 2009 at 12:50 PM, Thom Brown wrote: > > Hi, > > This should be simple, but for some reason I'm not quite sure what the > > solution is. I want to be able to update the value of a column for rows > > that have been updated. More specifically, if a row

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Adrian Klaver
On Sunday 22 November 2009 12:09:04 pm Thom Brown wrote: > 2009/11/22 Aaron Burnett > > > this is how I do it if this helps: > > > > column_name timestamp without time zone NOT NULL DEFAULT > > ('now'::text)::timestamp(6) without time zone > > > > Hi Aaron. Thanks for the reply, but that would on

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Scott Marlowe
On Sun, Nov 22, 2009 at 12:50 PM, Thom Brown wrote: > Hi, > This should be simple, but for some reason I'm not quite sure what the > solution is.  I want to be able to update the value of a column for rows > that have been updated.  More specifically, if a row is updated, I want it's > modified_da

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Aaron Burnett
this is how I do it if this helps: column_name timestamp without time zone NOT NULL DEFAULT ('now'::text)::timestamp(6) without time zone -Original Message- From: pgsql-general-ow...@postgresql.org on behalf of Thom Brown Sent: Sun 11/22/2009 2:50 PM To: PGSQL Mailing List Subject: [G

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Thom Brown
2009/11/22 Aaron Burnett > > this is how I do it if this helps: > > column_name timestamp without time zone NOT NULL DEFAULT > ('now'::text)::timestamp(6) without time zone > > Hi Aaron. Thanks for the reply, but that would only insert the current date upon insertion into the table, not when the