Is there any other way to accomplish NEW.TG_ARGV[0] in plpgsql, or am
I stuck writing a C function which will allow:
_value := getRecordValue(NEW, TG_ARGV[0]).


create table test(col1 int4);

create or replace function test() returns opaque as '
declare
  _value int4;
begin
  RAISE NOTICE ''Args: %'', TG_NARGS;
  RAISE NOTICE ''Column: %'', TG_ARGV[0];

  -- PARSE ERROR
  _value := NEW.TG_ARGV[0];

  RAISE NOTICE ''Data: %'', _value;
end;
' language 'plpgsql';

create trigger name BEFORE INSERT ON test
  FOR EACH ROW
  EXECUTE PROCEDURE test('col1');
--
Rod Taylor

Your eyes are weary from staring at the CRT. You feel sleepy. Notice
how restful it is to watch the cursor blink. Close your eyes. The
opinions stated above are yours. You cannot imagine why you ever felt
otherwise.




Sat, 2 Mar 2002 22:15:16 -0500
"Rod Taylor" <rbt@zort.ca>
plpgsql Field of Record issue
"Rod Taylor" <rbt@zort.ca> writes:
> Is there any other way to accomplish NEW.TG_ARGV[0] in plpgsql,

You could do something involving EXECUTE.

			regards, tom lane

Sun, 03 Mar 2002 15:33:56 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: plpgsql Field of Record issue 
> "Rod Taylor" <rbt@zort.ca> writes:
> > Is there any other way to accomplish NEW.TG_ARGV[0] in plpgsql,
>
> You could do something involving EXECUTE.

Then it tells me:: ERROR: NEW used in non-rule query

Tried a few other things, FOR .. IN EXECUTE .. which gives the same
error as above.

The below query gives me the same error as well -- though I'd be
surprised if it worked anyway:
CREATE TEMP TABLE test AS SELECT * FROM (NEW);

Creating a record and assigning NEW to it gives a parse error.


Sun, 3 Mar 2002 16:40:23 -0500
"Rod Taylor" <rbt@zort.ca>
Re: plpgsql Field of Record issue 