| From: | Ron Peterson <rpeterso(at)mtholyoke(dot)edu> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Subject: | on insert rule with default value |
| Date: | 2012-02-21 20:51:30 |
| Message-ID: | 20120221205130.GG29194@mtholyoke.edu |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tim Landscheidt | 2012-02-21 21:40:24 | Re: How to split up phone numbers? |
| Previous Message | Tom Lane | 2012-02-21 15:15:34 | Re: Function definitions - batch update |