Re: [GENERAL] Trouble with NEW

2012-07-19 Thread Alban Hertroys
On 19 Jul 2012, at 24:20, Bob Pawley wrote: When I substitute new.fluid_id for the actual fluid)id the expression returns the right value. Following is the table - CREATE TABLE p_id.fluids ( p_id_id integer, fluid_id serial, I think people meant the one on which the trigger fires ;)

Re: [GENERAL] Trouble with NEW

2012-07-19 Thread Bob Pawley
: [GENERAL] Trouble with NEW On 07/18/2012 03:20 PM, Bob Pawley wrote: When I substitute new.fluid_id for the actual fluid)id the expression returns the right value. Huh? I thought that was what was causing the problem. From your original post: where p_id.fluids.fluid_id = NEW.fluid_id; I

Re: [GENERAL] Trouble with NEW

2012-07-19 Thread Adrian Klaver
On 07/19/2012 06:43 AM, Bob Pawley wrote: The function is too long to copy. I separated it into another trigger function with just the update statement. Here is the error - ERROR: record new has no field fluid_id SQL state: 42703 Context: SQL statement update p_id.fluids set fluid_short =

Re: [GENERAL] Trouble with NEW

2012-07-19 Thread Bob Pawley
In all my reading of new and old I never made that connection. Thanks Adrian Bob -Original Message- From: Adrian Klaver Sent: Thursday, July 19, 2012 6:50 AM To: Bob Pawley Cc: Alan Hodgson ; pgsql-general@postgresql.org Subject: Re: [GENERAL] Trouble with NEW On 07/19/2012 06

Re: [GENERAL] Trouble with NEW

2012-07-19 Thread Adrian Klaver
On 07/19/2012 08:41 AM, Bob Pawley wrote: In all my reading of new and old I never made that connection. It makes more sense if you know what NEW and OLD represent. What follows is a simplification: 1)Postgres uses Multiversion Concurrency Control(MVCC). See here for brief intro:

Re: [GENERAL] Trouble with NEW

2012-07-19 Thread David Johnston
4) If you want to pull information from another table, you either need to set up a FOREIGN KEY relationship that you can leverage or you need to do a query in the trigger function that pulls in the necessary information. I do not get where the OR comes from. There is nothing magical about

Re: [GENERAL] Trouble with NEW

2012-07-19 Thread Adrian Klaver
On 07/19/2012 11:26 AM, David Johnston wrote: 4) If you want to pull information from another table, you either need to set up a FOREIGN KEY relationship that you can leverage or you need to do a query in the trigger function that pulls in the necessary information. I do not get where the OR

[GENERAL] Trouble with NEW

2012-07-18 Thread Bob Pawley
Hi I would appreciate some fresh eyes on this expression - update p_id.fluids set fluid_short = (select shape.text from shape, num_search where (select st_within(shape.wkb_geometry, st_geometryn(num_search.the_geom4, 1)) = 'true') and text !~ '[0-9]') where

Re: [GENERAL] Trouble with NEW

2012-07-18 Thread Rob Sargent
On 07/18/2012 12:07 PM, Bob Pawley wrote: Hi I would appreciate some fresh eyes on this expression - update p_id.fluids set fluid_short = (select shape.text from shape, num_search where (select st_within(shape.wkb_geometry, st_geometryn(num_search.the_geom4, 1)) = 'true')

Re: [GENERAL] Trouble with NEW

2012-07-18 Thread Alan Hodgson
On Wednesday, July 18, 2012 11:07:34 AM Bob Pawley wrote: Hi I would appreciate some fresh eyes on this expression - update p_id.fluids set fluid_short = (select shape.text from shape, num_search where (select st_within(shape.wkb_geometry,

Re: [GENERAL] Trouble with NEW

2012-07-18 Thread Bob Pawley
It's an insert after trigger function. The table has a column named fluid_id. Bob -Original Message- From: Alan Hodgson Sent: Wednesday, July 18, 2012 11:15 AM To: pgsql-general@postgresql.org Subject: Re: [GENERAL] Trouble with NEW On Wednesday, July 18, 2012 11:07:34 AM Bob Pawley

Re: [GENERAL] Trouble with NEW

2012-07-18 Thread Adrian Klaver
On 07/18/2012 12:28 PM, Bob Pawley wrote: It's an insert after trigger function. The table has a column named fluid_id. Can we see the table schema. What I am looking for is quoted column name that would preserve case. Bob -- Adrian Klaver adrian.kla...@gmail.com -- Sent via

Re: [GENERAL] Trouble with NEW

2012-07-18 Thread Alan Hodgson
On Wednesday, July 18, 2012 12:28:00 PM Bob Pawley wrote: It's an insert after trigger function. The table has a column named fluid_id. Bob Could you post the whole function? And a \d on the table? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to

Re: [GENERAL] Trouble with NEW

2012-07-18 Thread Bob Pawley
: [GENERAL] Trouble with NEW On 07/18/2012 12:28 PM, Bob Pawley wrote: It's an insert after trigger function. The table has a column named fluid_id. Can we see the table schema. What I am looking for is quoted column name that would preserve case. Bob -- Adrian Klaver adrian.kla