Peter Eisentraut wrote: > Am Mittwoch, 7. November 2007 schrieb Heikki Linnakangas: > > Peter Eisentraut wrote: > > > I wrote: > > >> I noticed this problem in 8.2 and 8.3: > > >> > > >> pei=# select mod( trunc( 1 ), 2 ); > > >> ERROR: 42883: function mod(double precision, integer) does not exist > > >> LINE 1: select mod( trunc( 1 ), 2 ); > > >> ^ > > > > > > I suppose there will be little interest in including the obvious > > > solution, namely > > > > > > CREATE FUNCTION pg_catalog.trunc(int) RETURNS int AS $$ SELECT $1; $$ > > > LANGUAGE SQL STRICT IMMUTABLE; > > > > It does sound totally useless... > > > > Why would you run a query like that in the first place? It seems like a > > useless query as it is. Is there a bigger story behind it? > > The "1" is substituted from somewhere else. If the value happens to be, say, > 1.5, it works, but not with 1 or 2.
Maybe as a workaround these are useful: alvherre=# select mod( trunc( 1.0 ), 2 ); mod ----- 1 (1 fila) alvherre=# select mod( trunc( 1::numeric ), 2 ); mod ----- 1 (1 fila) -- Alvaro Herrera Valdivia, Chile ICBM: S 39º 49' 18.1", W 73º 13' 56.4" Bob [Floyd] used to say that he was planning to get a Ph.D. by the "green stamp method," namely by saving envelopes addressed to him as 'Dr. Floyd'. After collecting 500 such letters, he mused, a university somewhere in Arizona would probably grant him a degree. (Don Knuth) ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org