pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: betty <liongliong@telkom.net>
To: pgsql-sql@postgresql.org
Subject: update column with rowtype
Date: Fri, 7 Feb 2003 15:26:36 +0700
Message-ID: <b1vq1o$krd$1@news.hub.org> (raw)

Hi..

I try "rowtype" in trigger, ex:
create or replace function fn_tr_aiu_pdcblc() returns trigger as '
declare
   c_pdcblc cursor for select * from t_pdcblc where fc_branch=new.fc_branch
and fc_bankacct=new.fc_bankacct;
   balance decimal(30,5);
   row_pdcblc t_pdcblc%rowtype;
begin
    balance:=0;
    if (select count(*) from t_pdcblc where fc_branch=new.fc_branch and
fc_bankacct=new.fc_bankacct and fd_trxdate<new.fd_trxdate)>0 then
        balance:=new.fm_balance from t_pdcblc where fc_branch=new.fc_branch
and fc_bankacct=new.fc_bankacct and fd_trxdate<new.fd_trxdate;
    end if;
    open c_pdcblc;
    for c_pdc in 1..(select count(*) from t_pdcblc where
fc_branch=new.fc_branch and fc_bankacct=new.fc_bankacct and
fd_trxdate>=new.fd_trxdate) loop
        fetch c_pdcblc into row_pdcblc;
        row_pdcblc.fm_balance :=
balance+row_pdcblc.fm_masuk-row_pdcblc.fm_keluar;
        raise  notice ''balance %'',row_pdcblc.fm_balance;
        new.fm_balance := row_pdcblc.fm_balance;
    end loop;
    close c_pdcblc;
    return new;
end;' language 'plpgsql';

the result of this trigger is;
  oid      |     fd_trxdate                |  fm_masuk    | fm_keluar |
fm_balance
--------+---------------------    +------------ +-----------+------------
 562784 | 2003-02-06 00:00:00 | 1000.00000 |   0.00000 |    0.00000

and which command  i could used to fill column fm_balance with 1000?
please gimme some idea...???

thank's
betty


thank's





Message-ID: <b1vq1o$krd$1@news.hub.org>
Permalink:  ../b1vq1o$krd$1@news.hub.org/
Also on:    postgresql.org/message-id/b1vq1o$krd$1@news.hub.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: liongliong@telkom.net
  Subject: Re: update column with rowtype
  In-Reply-To: <b1vq1o$krd$1@news.hub.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox