[SQL] conversi ms-sql7 vs postgresql 7.3

2003-02-06 Thread betty
Hi..

I have table xx:
id  debet   credit   balance
1  10000   0
2   2000   0   0
3 0   2500 0
4 0 100 0

command in ms-sql 7 can use calculate field (column) balance from id=1 to
id=4:
"update xx set bal=balance=bal+debet-credit"
result:
id  debet   credit   balance
1  10000  1000
2   2000   0   3000
3 0   2500 500
4 0 100 400

How command sql can use in psotgresql 7.3?

thank's a lot
betty.




---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



[SQL] update column with rowtype

2003-02-07 Thread betty
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_trxdate0 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) 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.0 |   0.0 |0.0

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

thank's
betty


thank's



---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster



[SQL] query 2 database

2003-03-21 Thread betty
hi...

Can anybody help me, can't i make "query > 1 table in different database
(but not schema)"  in postgre 7.3?

thanks
betty




---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly