PL/PGSQL arithmetic errors

Поиск
Список
Период
Сортировка
Искать
От
jc_mich
Тема
PL/PGSQL arithmetic errors
Дата
Msg-id
22795583.post@talk.nabble.com
Список
Дерево обсуждения
PL/PGSQL arithmetic errors jc_mich <juan.michaca@paasel.com>
Re: PL/PGSQL arithmetic errors Justin <justin@emproshunts.com>

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 по дате отправления
От: Michael Glaesemann
Дата:
От: jc_mich
Дата:
Сообщение: PL/PGSQL arithmetic errors
FAQ