pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Boettcher <bboett@erm1.u-strasbg.fr>
To: pgsql-sql@postgresql.org
Subject: pgpl-problem, what's wrong with my loop?
Date: Mon, 20 Nov 2000 17:21:05 +0100
Message-ID: <20001120172105.E25191@erm1.u-strasbg.fr> (raw)
In-Reply-To: <20001120165133.D25191@erm1.u-strasbg.fr>
References: <20001120165133.D25191@erm1.u-strasbg.fr>

Hello,

once more, i ran into a problem....
i got no syntax error, i don't know how to debug, except for raising
exceptions....  the loop never executes....  making the select call by hand
with fixed values, returns a result...  but the second raise is never passed
with the function...so something seems wrong....

 
CREATE FUNCTION accSum(text,text) RETURNS int4 AS '
  DECLARE
  col ALIAS FOR $1;
  sumup ALIAS FOR $2;
  actsum journal.amount%TYPE;
  arow journal%ROWTYPE;
  conversion float4;
  temp float4;
  sum int4;
  BEGIN
  sum := 0;
  RAISE NOTICE ''stats %=% '', col,sumup;
  FOR arow IN SELECT currency,amount FROM journal WHERE col=sumup LOOP
     RAISE NOTICE ''% current line: %'', arow.id,arow.amount;
     SELECT conv FROM currencies WHERE tag=arow.currency INTO conversion;
     temp := conversion*arow.amount+0.5;
     sum := sum + temp;
     END LOOP;
     return sum; 
  END;    
          ' LANGUAGE 'plpgsql';

as sayd :
fibu=>  select accSum('plus','102');
NOTICE:  stats plus=102 
 accsum 
--------
      0
(1 row)

fibu=> SELECT currency,amount FROM journal WHERE plus=102;
 currency | amount 
----------+--------
 EUR      | 100000
 EUR      | 100000
 EUR      | 100000
 EUR      | 100000
 EUR      | 100000
(5 rows)

surely some stupid error somewhere.....

-- 
ciao bboett
==============================================================
bboett@earthling.net
http://inforezo.u-strasbg.fr/~bboett http://erm1.u-strasbg.fr/~bboett
===============================================================
the total amount of intelligence on earth is constant.
human population is growing....



view thread (5+ messages)  latest in thread

Message-ID: <20001120172105.E25191@erm1.u-strasbg.fr>
Permalink:  ../20001120172105.E25191@erm1.u-strasbg.fr/
Also on:    postgresql.org/message-id/20001120172105.E25191@erm1.u-strasbg.fr

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: bboett@erm1.u-strasbg.fr
  Subject: Re: pgpl-problem, what's wrong with my loop?
  In-Reply-To: <20001120172105.E25191@erm1.u-strasbg.fr>
  References: <20001120165133.D25191@erm1.u-strasbg.fr> <20001120172105.E25191@erm1.u-strasbg.fr>

* 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