-- funzione per trasformare un text,char,varchar in un float... -- CAST(text AS float); drop function float8(text); create function float8(text) returns float8 as 'declare f float8; begin IF $1 ISNULL THEN RETURN ''0''; ELSE f:= trim($1); RETURN f; END IF; end; ' language 'plpgsql'; create table a (t text, c char(10), v varchar); insert into a values ('1.2','1.3','1.4'); insert into a values ('1.2'); select cast(t as float), cast(c as float), cast(v as float) from a; select * from a; select cast('12' as float); drop table a;