From: Scott Royston <scroyston@mac.com>
To: pgsql-sql@postgresql.org
Subject: can't cast varchar as integer?
Date: Tue, 14 May 2002 13:56:33 -0500
Message-ID: <4EE21904-676C-11D6-BF4D-000393577144@mac.com> (raw)
Mac OSX, postgresql 7.2.1
what's the reasoning behind not being able to cast a varchar as
integer? this seems very weird to me:
LEDEV=# create table test (foo as varchar(5), bar as text);
ERROR: parser: parse error at or near "as"
LEDEV=# create table test (foo varchar(5), bar text);
CREATE
LEDEV=# insert into test (foo, bar) values ('123', '123');
INSERT 409490 1
LEDEV=# select * from test;
foo | bar
-----+-----
123 | 123
(1 row)
LEDEV=# select cast(foo as integer) from test;
ERROR: Cannot cast type 'character varying' to 'integer'
LEDEV=# select cast(bar as integer) from test;
bar
-----
123
(1 row)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: scroyston@mac.com
Subject: Re: can't cast varchar as integer?
In-Reply-To: <4EE21904-676C-11D6-BF4D-000393577144@mac.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox