problems with function pg_catalog.btrim(date)

From: Karina Guardado <karina(dot)guardado(at)ues(dot)edu(dot)sv>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: problems with function pg_catalog.btrim(date)
Date: 2009-08-27 22:21:34
Message-ID: 4A9706EE.7060600@ues.edu.sv
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi everybody,

I hope some one can help me, I have created the following function but
I always get the error that there is not function
pg_catalog.btrim(date), in the version postgresql 8.1 it worked but now
it does not so I don't know if it is related with a configuration
problem of the postgresql or somethin in the function code :

thanks

karina

CREATE FUNCTION edad(date) RETURNS integer
AS $_$
DECLARE
fechnac ALIAS FOR $1;
dia_nac integer;
mes_nac integer;
anho_nac integer;
fecha_nac date;
fecha_temp text;
hoy date;
dia integer;
mes integer;
anho integer;
temp integer;
edad integer;

BEGIN

hoy := current_date;
hoy := date(trim(hoy));

fecha_nac:= date(trim(fechnac));
fecha_temp:=CAST(fecha_nac AS text );

dia_nac :=CAST(substring(fecha_temp from 1 for 2) AS integer );
mes_nac := CAST (substring(fecha_temp from 4 for 2) AS integer);
anho_nac :=CAST(substring(fecha_temp from 7 for 4) AS integer );

dia :=CAST(substring(hoy from 1 for 2) AS integer );
mes := CAST (substring(hoy from 4 for 2) AS integer);
anho := CAST(substring(hoy from 7 for 4) AS integer );

edad:= (anho-anho_nac)-1;

IF mes+1-mes_nac < 0 THEN
RETURN edad;
END IF;

IF mes+1-mes_nac < 0 THEN
RETURN edad;
END IF;

IF mes+1-mes_nac > 0 THEN
RETURN edad+1;
END IF;

IF dia-dia_nac >= 0 THEN
RETURN edad+1;
ELSE
RETURN edad;
END IF;
END;

$_$
LANGUAGE plpgsql;

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2009-08-28 00:01:54 Re: Viable alternatives to SQL?
Previous Message Thomas Kellerer 2009-08-27 21:32:29 Re: GUI to edit a table's content