Re: [GENERAL] Emulating trigger BEFORE SELECT behavior

2013-04-18 Thread Atri Sharma
> Why you just create your track function and a view to call it? > > Example: > > BEGIN; > > CREATE TABLE foo (id SERIAL PRIMARY KEY, data TEXT); > CREATE TABLE foo_track(tracktime TIMESTAMP DEFAULT now(), foo_row foo); > > INSERT INTO foo (data) SELECT 'Some Data'||id FROM generate_series(1,10) AS

Re: [GENERAL] Emulating trigger BEFORE SELECT behavior

2013-04-18 Thread Fabrízio de Royes Mello
On Thu, Apr 18, 2013 at 11:02 AM, Atri Sharma wrote: > > [...] > > One way I was thinking of was creating an updatable view, which is > initialized to NULL. As SELECT queries take place, I can update the > view to include the new rows. > > Why you just create your track function and a view to cal

Re: [GENERAL] Emulating trigger BEFORE SELECT behavior

2013-04-18 Thread Adrian Klaver
On 04/18/2013 07:19 AM, Atri Sharma wrote: So what would you run the SELECT against, another view or table? No, what I meant was: SELECT on main table: fires a rule which updates a view V1 Now, essentially, view V1 has the data I was trying to acquire originally through BEFORE INSERT trigger

Re: [GENERAL] Emulating trigger BEFORE SELECT behavior

2013-04-18 Thread Atri Sharma
> > So what would you run the SELECT against, another view or table? No, what I meant was: SELECT on main table: fires a rule which updates a view V1 Now, essentially, view V1 has the data I was trying to acquire originally through BEFORE INSERT trigger. When I need the data, I can query view V

Re: [GENERAL] Emulating trigger BEFORE SELECT behavior

2013-04-18 Thread Adrian Klaver
On 04/18/2013 07:02 AM, Atri Sharma wrote: How about a RULE: http://www.postgresql.org/docs/9.2/interactive/sql-createrule.html Rules can be tricky, so I would at least skim through: http://www.postgresql.org/docs/9.2/interactive/rules.html Thanks. It looks like that it is another way to cr

Re: [GENERAL] Emulating trigger BEFORE SELECT behavior

2013-04-18 Thread Atri Sharma
> How about a RULE: > > http://www.postgresql.org/docs/9.2/interactive/sql-createrule.html > > Rules can be tricky, so I would at least skim through: > > http://www.postgresql.org/docs/9.2/interactive/rules.html Thanks. It looks like that it is another way to create a view, which is probably not

Re: [GENERAL] Emulating trigger BEFORE SELECT behavior

2013-04-18 Thread Adrian Klaver
On 04/18/2013 05:12 AM, Atri Sharma wrote: On Thu, Apr 18, 2013 at 5:35 PM, Alfonso Afonso wrote: Hi Atri Maybe you could think different and, instead of do a "before select trigger", you can: - create a store procedure with result is a recordset - create a view If you can't... could you pl

Re: [GENERAL] Emulating trigger BEFORE SELECT behavior

2013-04-18 Thread Atri Sharma
On Thu, Apr 18, 2013 at 5:35 PM, Alfonso Afonso wrote: > Hi Atri > > Maybe you could think different and, instead of do a "before select trigger", > you can: > > - create a store procedure with result is a recordset > - create a view > > If you can't... could you please explain us a bit more abou

Re: [GENERAL] Emulating trigger BEFORE SELECT behavior

2013-04-18 Thread Alfonso Afonso
Hi Atri Maybe you could think different and, instead of do a "before select trigger", you can: - create a store procedure with result is a recordset - create a view If you can't... could you please explain us a bit more about the requirements about this before action? Good luck Regards El

[GENERAL] Emulating trigger BEFORE SELECT behavior

2013-04-18 Thread Atri Sharma
Hi all, I need a tool which allows me to do a task before every SELECT on a table. Specifically,the behavior I would get with a BEFORE SELECT trigger. Please advice me on this. Regards, Atri -- Regards, Atri l'apprenant -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org)