From: | Roberto Mello <rmello(at)cc(dot)usu(dot)edu> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | daq <daq(at)ugyvitelszolgaltato(dot)hu>, Luke Pascoe <luke(dot)p(at)kmg(dot)co(dot)nz>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: CAST from VARCHAR to INT |
Date: | 2003-01-24 19:03:56 |
Message-ID: | 20030124190356.GC20178@cc.usu.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Fri, Jan 24, 2003 at 10:42:29AM -0500, Tom Lane wrote:
> daq <daq(at)ugyvitelszolgaltato(dot)hu> writes:
> > Make your life easier! :) You must write a function like
> > this:
>
> > create function "int4"(character varying) returns int4 as '
> > DECLARE
> > input alias for $1;
> > BEGIN
> > return (input::text::int4);
> > END;
> > ' language 'plpgsql';
>
> > When you try the cast varchar_field::integer or varchar_field::int4 Postgres call
> > the function named int4 and takes varchar type parameter.
>
> Note that as of 7.3 you need to issue a CREATE CAST command; the name of
> the function is not what drives this anymore. (Though following the old
> naming convention that function name == return type still seems like a
> good idea.)
Wow, I didn't even know of either of these features. Sounds useful.
-Roberto
--
+----| Roberto Mello - http://www.brasileiro.net/ |------+
+ Computer Science Graduate Student, Utah State University +
+ USU Free Software & GNU/Linux Club - http://fslc.usu.edu/ +
Friends encourage friends to use Win(e)dows - under Linux!
From | Date | Subject | |
---|---|---|---|
Next Message | David Durst | 2003-01-24 19:39:07 | Getting multiple rows in plpgsql function |
Previous Message | Guy Fraser | 2003-01-24 18:46:02 | Re: Scheduling Events? |