Re: Question on Rules

From: <mgould(at)isstrucksoftware(dot)net>
To: "David Johnston" <polobo(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Question on Rules
Date: 2012-02-20 17:07:18
Message-ID: 20120220100718.c760ddbd7c0975bc4b045766db7d895c.3e5fd92639.wbe@email16.secureserver.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general









David,





Are rules deprecated?





Michael Gould


Intermodal Software Solutions, LLC


904-226-0978









-------- Original Message --------

Subject: Re: [GENERAL] Question on Rules

From: "David Johnston" polobo(at)yahoo(dot)com

Date: Sun, February 19, 2012 9:16 pm

To: mgould(at)isstrucksoftware(dot)net, pgsql-general(at)postgresql(dot)org

-----Original Message-----

From: pgsql-general-owner(at)postgresql(dot)org [mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of mgould(at)isstrucksoftware(dot)net

Sent: Saturday, February 18, 2012 5:17 AM

To: pgsql-general(at)postgresql(dot)org

Subject: [GENERAL] Question on Rules

I am creating a rule which will copy a record when it is changed to a audittable. My question is that the first column is a UUID data type with a defined as auditaccessorid uuid DEFAULT

isscontrib.uuid_generate_v4() NOT NULL,

Right now I've got that set to NULL to allow the parser to "compile".

What value should I have in here since I want a newly created UUID?

CREATE RULE log_accessor AS ON UPDATE TO iss.accessor

WHERE NEW.* OLD.*

DO INSERT INTO iss.auditaccessor VALUES (NULL,

'C',

new.loaddtlid,

new.seqno,

new.billable,

new.payind,

new.code,

new.description,

new.ref,

new.tractororcarrierflag,

new.tractororcarrierno,

new.tractorpct,

new.charge,

new.type,

new.checkdate,

new.checkno,

new.processed,

new.itemflag,

new.tractortermloc,

new.cost,

new.batchno,

new.editdatetime,

new.edituser);

Best Regards,

Michael Gould

Intermodal Software Solutions, LLC

904-226-0978

--------------------------------------------------------------------

INSERT INTO table (serial_col1) VALUES (DEFAULT);

Also, I presume you have a good reason for using a RULE instead of a TRIGGER? If not you should default to a TRIGGER for this kind of behavior.

David J.

--

Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)

To make changes to your subscription:

http://www.postgresql.org/mailpref/pgsql-general





Responses

Browse pgsql-general by date

  From Date Subject
Next Message hubert depesz lubaczewski 2012-02-20 17:29:50 Re: How can I get list of views that are using given column in table?
Previous Message Andy Colson 2012-02-20 15:54:11 Re: How to split up phone numbers?