[SQL] passing new/old record in pl/pgsql trigger functions to other functions

2004-05-30 Thread basic
Hi,
  In Postgresql version 7.4.1 How does one pass new/old record in a 
pl/pgsql trigger function to other functions? I tried to pass it 
directly but the select/perform statement caused an error saying "NEW 
used in query that is not in a rule". I've tried 'rename' in the declare 
block but that didn't work at all (I get 'invalid column', which I 
assume it means rename did not work at all). Besides copying the record 
columns one by one, is there any other way to do this?

--
basic
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
  http://www.postgresql.org/docs/faqs/FAQ.html


Re: [SQL] plpgsql - Insert from a record variable?

2004-06-21 Thread basic
Phil Endecott wrote:
> !!  execute ''column_values :=
> !! column_values || quote_literal(r.'' || cr.column_name || '')'';
I'm guessing you want something like
FOR rec IN EXECUTE ''select column_values || quote_literal(r.'' || cr.column_name || 
'') alias column_values''; LOOP
column_values := rec.column_values;
END LOOP;
another suggestion, rather than do
>if not first then
>  column_names := column_names || '', '';
>  column_values := column_values || '', '';
>  first := false;
>end if;
why not use two arrays and append the name/values using array_append() and use 
array_to_string() to join them after that?
--
basic
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster