X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 668F39FB417 for ; Thu, 31 Aug 2006 18:43:07 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 24042-08 for ; Thu, 31 Aug 2006 21:43:03 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.177]) by postgresql.org (Postfix) with ESMTP id F1C499FB415 for ; Thu, 31 Aug 2006 18:43:02 -0300 (ADT) Received: by py-out-1112.google.com with SMTP id d80so885490pyd for ; Thu, 31 Aug 2006 14:42:52 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=T3lNyGzdGv8a9zBO3mIPf0dFtvcrf4IoJ37czJFywI5On5ijVvtSFUAdSF4fJyp6I45eJGf7f4ljyFUyUzUiDm3HoLYJPxsxbS6OppDeQv+DHh/w/jx1K+s56dlaVWZg7dBRI+l6m++sNJHbtFgMgfiZiIIljC+dXB3WrtxOXYM= Received: by 10.35.49.4 with SMTP id b4mr1512740pyk; Thu, 31 Aug 2006 14:42:51 -0700 (PDT) Received: by 10.35.80.9 with HTTP; Thu, 31 Aug 2006 14:42:50 -0700 (PDT) Message-ID: Date: Thu, 31 Aug 2006 16:42:50 -0500 From: "Aaron Bono" To: "Ezequias Rodrigues da Rocha" Subject: Re: Trigger with Stored Procedure [Client Points] Cc: pgsql-sql@postgresql.org In-Reply-To: <55c095e90608311006l2ad93607p6779930c248d1968@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_60964_7026032.1157060570337" References: <55c095e90608300456x4a24948fw9edc24aaa253c256@mail.gmail.com> <55c095e90608311006l2ad93607p6779930c248d1968@mail.gmail.com> X-Google-Sender-Auth: 4de53ded0bcb43f0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.334 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, HTML_50_60, HTML_MESSAGE, SPF_PASS X-Spam-Level: X-Archive-Number: 200608/253 X-Sequence-Number: 26211 ------=_Part_60964_7026032.1157060570337 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 8/31/06, Ezequias Rodrigues da Rocha wrote: > > Bono, > > I must check each insert on my Points(each shop generate a new line on > Points table). > > When I insert the record on points I must see the field Value(on > points table already) and update the Client.Points field based in some > rule. My fear is not get correct row and do not update the correct client. > > Any help would be very welcome. > > Regards > Ezequias > > 2006/8/31, Aaron Bono < postgresql@aranya.com>: > > > On 8/30/06, Ezequias Rodrigues da Rocha > > wrote: > > > > > Hi list, > > > > > > I have a table like this: > > > > > > Points > > > --------------------------------- > > > Id > > > operation > > > value > > > > > > and another two tables like this > > > > > > Client Rule > > > ------------------------ ----------------------- > > > id id > > > name percent > > > Points > > > > > > > > > ps: The Points table is a table that represent each moviment of the > > > Client. > > > > > > > > > I need to make a trigger that see after all insert on Points table and > > > update the client table based on the percent on the Rule table. > > > > > > Anyone that would like to help me I will be very welcomed. > > > > > > > > > I am not exactly sure what you are trying to do here. Can you provide > > an example of the data and what you want to occur? > > > Please include the list when you reply (reply to all). So are you saying you need to add foreign keys to the tables? Or are the rules what dictate what records should be updated? From what you have said and what I can see of your tables, the rule and points tables need foreign keys to the clients table so you know what clients the points and rules are for. Of course I am guessing based off the very limited information you have provided. If we are to help you, you really need to provide some examples. What kind of rules are you talking about? ** ================================================================== Aaron Bono Aranya Software Technologies, Inc. http://www.aranya.com http://codeelixir.com ================================================================== ------=_Part_60964_7026032.1157060570337 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 8/31/06, Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com> wrote:
Bono,

I must check each insert on my Points(each shop generate a new line on Points table).

When I insert  the  record  on points  I must  see the field Value(on points table already) and update the Client.Points field based in some rule. My fear is not get correct row and do not update the correct client.

Any help would be very welcome.

Regards
Ezequias

2006/8/31, Aaron Bono < postgresql@aranya.com>:
On 8/30/06, Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com> wrote:
Hi list,

I have a table like this:

Points
---------------------------------
Id
operation
value

and another two tables like this

Client                                        Rule
------------------------                       -----------------------
id                                             id
name                                       percent
Points


ps: The Points table is a table that represent each moviment of the Client.


I need to make a trigger that see after all insert on Points table and update the client table based on the percent on the Rule table.

Anyone that would like to help me I will be very welcomed.

 
I am not exactly sure what you are trying to do here.  Can you provide an example of the data and what you want to occur?

 
Please include the list when you reply (reply to all).

So are you saying you need to add foreign keys to the tables?  Or are the rules what dictate what records should be updated?  From what you have said and what I can see of your tables, the rule and points tables need foreign keys to the clients table so you know what clients the points and rules are for.  Of course I am guessing based off the very limited information you have provided.

If we are to help you, you really need to provide some examples.  What kind of rules are you talking about?

==================================================================
   Aaron Bono
   Aranya Software Technologies, Inc.
   http://www.aranya.com
   http://codeelixir.com
================================================================== ------=_Part_60964_7026032.1157060570337--