From: Ron Peterson <rpeterso@mtholyoke.edu>
To: pgsql-sql@postgresql.org
Subject: on insert rule with default value
Date: Tue, 21 Feb 2012 15:51:30 -0500
Message-ID: <20120221205130.GG29194@mtholyoke.edu> (raw)
My rule below does not insert the the same uuid value into the test_log
table as is created in the test table when I insert a new value. I know
I've worked through this before, but I'm not remembering why this is.
What's a right way to do this?
create table test (
anid
uuid
not null
default encode( gen_random_bytes( 16 ), 'hex' )::uuid
primary key,
value
text
);
create table test_log (
anid
uuid,
value
text,
op
text,
attime
timestamp with time zone
);
create rule test_rule_a as
on insert to test do (
insert into test_log ( anid, value, op, attime )
values ( new.anid, new.value, 'insert', now() )
);
--
Ron Peterson
Network & Systems Administrator
Mount Holyoke College
http://www.mtholyoke.edu/~rpeterso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: rpeterso@mtholyoke.edu
Subject: Re: on insert rule with default value
In-Reply-To: <20120221205130.GG29194@mtholyoke.edu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox