How to catch a command

Lists: pgsql-novice
From: Humberto Carvalho <carvalho(dot)humberto(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: How to catch a command
Date: 2005-07-22 13:13:42
Message-ID: 84c833550507220613734496a4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Hello,

Anyone know if it's possible to catch a Select, delete, update or
insert command before he takes effect in the postgres database?

I hope someone can help me.

thanks

--
Humberto Carvalho


From: Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>
To: Humberto Carvalho <carvalho(dot)humberto(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to catch a command
Date: 2005-07-22 14:38:23
Message-ID: 6e8ac93bbca48e612ce5795ed7ff4403@mail.nih.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice


On Jul 22, 2005, at 9:13 AM, Humberto Carvalho wrote:

> Hello,
>
> Anyone know if it's possible to catch a Select, delete, update or
> insert command before he takes effect in the postgres database?
>

For insert and update you can use triggers. Not select, though.

Sean


From: John DeSoi <desoi(at)pgedit(dot)com>
To: Humberto Carvalho <carvalho(dot)humberto(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to catch a command
Date: 2005-07-22 15:56:19
Message-ID: 66F1B650-7A60-46F2-83E1-54B2C0FB0753@pgedit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice


On Jul 22, 2005, at 9:13 AM, Humberto Carvalho wrote:

> Anyone know if it's possible to catch a Select, delete, update or
> insert command before he takes effect in the postgres database?
>
> I hope someone can help me.

You can use triggers for delete, update, and insert. Rules can work
on everything including select statements. See

http://www.postgresql.org/docs/8.0/interactive/sql-createrule.html

John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


From: Humberto Carvalho <carvalho(dot)humberto(at)gmail(dot)com>
To:
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to catch a command
Date: 2005-07-22 16:01:36
Message-ID: 84c833550507220901790a3ced@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

ok...

in this case the rules don't work, because the db that i use don't
have any data, only the structure. So i need to send the command to
the real databases that are in a diferente server.

So if i use triggers i can't execute select's.

Thks

Humberto Carvalho

On 7/22/05, John DeSoi <desoi(at)pgedit(dot)com> wrote:
>
> On Jul 22, 2005, at 9:13 AM, Humberto Carvalho wrote:
>
> > Anyone know if it's possible to catch a Select, delete, update or
> > insert command before he takes effect in the postgres database?
> >
> > I hope someone can help me.
>
> You can use triggers for delete, update, and insert. Rules can work
> on everything including select statements. See
>
> http://www.postgresql.org/docs/8.0/interactive/sql-createrule.html
>
>
>
>
>
>
> John DeSoi, Ph.D.
> http://pgedit.com/
> Power Tools for PostgreSQL
>
>

--
Humberto Carvalho


From: "Mike Fahrenkrog" <mikef(at)travelpost(dot)com>
To: "'Humberto Carvalho'" <carvalho(dot)humberto(at)gmail(dot)com>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: How to catch a command
Date: 2005-07-22 17:26:47
Message-ID: 20050722172842.C92895280C@svr1.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

> On Jul 22, 2005, at 9:13 AM, Humberto Carvalho wrote:

> the db that i use don't have any data, only the structure.
> So i need to send the command to the real databases that are
> in a diferente server.

Interesting architecture. Is not having any data in the front db a design
constraint? If so, based on what -- very limited resources on the front db
server, e.g. embedded or mobile device? Just curious. If the front db server
is not actually constrained, you may want to consider using replication
instead.

As far as I know, your front db would have to contain the data for
replication to work. Perhaps someone knows of a simple or reliable way to
set up Slony replication while keeping data out of the publisher. In
general, though, replication would be the most straightforward and reliable
way to get your data to the "real" database.

Check out:
http://gborg.postgresql.org/project/slony1/projdisplay.phpalowing

Regards,
Mike