Re: function on trigger - Mailing list pgsql-general

From David Johnston
Subject Re: function on trigger
Date
Msg-id 23226B29-9B3A-4778-B7C2-7C990897B712@yahoo.com
Whole thread Raw
In response to function on trigger  (Marcos Hercules Santos <mhercs@gmail.com>)
List pgsql-general
On Aug 31, 2011, at 18:39, Marcos Hercules Santos <mhercs@gmail.com> wrote:

> hi guys
>
> I'm newbie in Psql and I'm trying to build one function  in order to
> count the products for each supplier. So i'm gonna put it quite simply
> though this example
>
>
> Please, consider a table called books with the following fields
>
> bookid, title, price, idPublisher
>
>
>
> and one another table called publisher
>
> Idpublisher, name, city, Books
>
>
> Being in that last field from Publisher, called book, I gotta have the
> amount of published books for each publisher.

Is there a question somewhere?


>
Do not be tempted by the dark side Marcos.  Create a view that uses a join and a count.  Only if you have significant
performanceissues would you then consider materializing that view. 

If you insist, or simply want to learn, read the sections on UPDATE, CREATE TRIGGER, and CREATE FUNCTION.  Try doing it
followingthose examples.  Ask more specific questions if something specific stumps you. 

Do it incrementally.  Get the raw SQL UPDATE working then create the trigger and function and get those working.  Then
combinethe two. 

David J.


pgsql-general by date:

Previous
From: Marcos Hercules Santos
Date:
Subject: function on trigger
Next
From: John R Pierce
Date:
Subject: Re: function on trigger