PL/PGSQL arithmetic errors - Mailing list pgsql-general

From jc_mich
Subject PL/PGSQL arithmetic errors
Date
Msg-id 22795583.post@talk.nabble.com
Whole thread Raw
Responses Re: PL/PGSQL arithmetic errors
List pgsql-general
Hi all!

I'm developing an algorithm with PL/PGSQL using statistical operations from
a table. I have several differences between expected results and the results
generated by the function.

I want to know if there are differences in arithmetic operation sintax or if
there's any special arithmetical operators precedence between pl/pgsql and
other languages.

My code looks like this:

FOR iterator1 IN SELECT period, AVG(col1) AS avg_col1, STDDEV(col1) AS
dev_col1, AVG(col2) AS avg_col2, STDDEV(col2) AS dev_col2 FROM scheme.table
GROUP BY period ORDER BY period LOOP
    FOR iterator2 IN SELECT period, id, col2, col1 FROM scheme.table WHERE col1
IS NOT NULL LOOP
        IF grav = 0 THEN
            _standata := (iterator2.col1 - iterator1.avg_col1) / iterator1.dev_col1;
            ELSE
                _standata := (iterator2.col2 - iterator1.avg_col2) / iterator1.dev_col2;
        END IF;
        UPDATE scheme.table SET standata = _standata WHERE id = iterator2.id AND
period=iterator2.period;
        _standata := 0.0;
    END LOOP;
END LOOP;

Thanks!
--
View this message in context: http://www.nabble.com/PL-PGSQL-arithmetic-errors-tp22795583p22795583.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


pgsql-general by date:

Previous
From: Michael Glaesemann
Date:
Subject: Re: i have a problem with judge some words contain chinese word!
Next
From: jc_mich
Date:
Subject: PL/PGSQL arithmetic errors