Search Postgresql Archives

Re: function on trigger

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Aug 31, 2011, at 18:39, Marcos Hercules Santos <mhercs@xxxxxxxxx> 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 performance issues 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 following those 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 combine the two.

David J.


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux