From: | Sergey Konoplev <gray(dot)ru(at)gmail(dot)com> |
---|---|
To: | "Simon (dot)(dot)(dot)" <wedgetail_e(at)hotmail(dot)com> |
Cc: | "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Testing if a Column Exists in a NEW record of a Trigger Function |
Date: | 2014-01-07 22:44:58 |
Message-ID: | CAL_0b1unxK5xTPKw2SYtUEm+gP6xYbP5ktiC-o-UUHZT7G7j1w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Mon, Jan 6, 2014 at 8:15 PM, Simon ... <wedgetail_e(at)hotmail(dot)com> wrote:
> As part of the Audit process in my psql database, I have a standard set of
> columns "InsertBy", "InsertTime", "LastUpdateBy" & "LastUpdateTme". I use a
> standard Trigger function [listed below] to ensure the correct details are
> added to each record.
> However, on some data tables where data is only imported and not updated,
> the "Update" columns are not required.
>
> As such, is there a way to test the NEW record variable to see if the column
> "LastUpdateBy" exists? I could not find any information in the manual to
> describe how this might be done.
It can be done by installing the hstore [1] extension and checking it as
hstore(NEW) ? 'LastUpdateBy'
[1] http://www.postgresql.org/docs/9.3/interactive/hstore.html
--
Kind regards,
Sergey Konoplev
PostgreSQL Consultant and DBA
http://www.linkedin.com/in/grayhemp
+1 (415) 867-9984, +7 (901) 903-0499, +7 (988) 888-1979
gray(dot)ru(at)gmail(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Sameer Kumar | 2014-01-08 05:52:36 | Re: Master-slave failover question |
Previous Message | David Johnston | 2014-01-07 20:17:06 | Re: how to add 'time with time zone' data types and 'interval' data types |