Re: CAST from VARCHAR to INT - Mailing list pgsql-sql

From daq
Subject Re: CAST from VARCHAR to INT
Date
Msg-id 21242862808.20030124112835@ugyvitelszolgaltato.hu
Whole thread Raw
In response to CAST from VARCHAR to INT  ("Luke Pascoe" <luke.p@kmg.co.nz>)
Responses Re: CAST from VARCHAR to INT
List pgsql-sql
Hello!

Like others said you can't cast varchar to int directly.
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.


DAQ



pgsql-sql by date:

Previous
From: Achilleus Mantzios
Date:
Subject: Re: Scheduling Events?
Next
From: Tomasz Myrta
Date:
Subject: Re: quastions about primary key