Re: [SQL] CAST from VARCHAR to INT

2003-01-27 Thread Luke Pascoe
EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Friday, January 24, 2003 6:58 PM Subject: Re: [SQL] CAST from VARCHAR to INT > > > (Postgres 7.2.1) > > > > I screwed up when I was designing a table a while back and made a column a > > VARCHAR that referenced (a

Re: [SQL] CAST from VARCHAR to INT

2003-01-24 Thread Tom Lane
daq <[EMAIL PROTECTED]> 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

Re: [SQL] CAST from VARCHAR to INT

2003-01-24 Thread daq
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); E

Re: [SQL] CAST from VARCHAR to INT

2003-01-23 Thread Tom Lane
"Luke Pascoe" <[EMAIL PROTECTED]> writes: > Now I'm trying to correct my mistake, I've created a new table and I'm > trying to INSERT INTO...SELECT the data into it, but it's complaining that > it can't stick a VARCHAR into an INT. All the values in the column are valid > integers (the foreign key

Re: [SQL] CAST from VARCHAR to INT

2003-01-23 Thread Bhuvan A
> (Postgres 7.2.1) > > I screwed up when I was designing a table a while back and made a column a > VARCHAR that referenced (and should have been) an INT. > > Now I'm trying to correct my mistake, I've created a new table and I'm > trying to INSERT INTO...SELECT the data into it, but it's compla

[SQL] CAST from VARCHAR to INT

2003-01-23 Thread Luke Pascoe
(Postgres 7.2.1) I screwed up when I was designing a table a while back and made a column a VARCHAR that referenced (and should have been) an INT. Now I'm trying to correct my mistake, I've created a new table and I'm trying to INSERT INTO...SELECT the data into it, but it's complaining that it c