From: | Oliver Elphick <olly(at)lfix(dot)co(dot)uk> |
---|---|
To: | Matthew Nuzum <cobalt(at)bearfruit(dot)org> |
Cc: | Postgres General List <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: argh... can't cast varchar to int |
Date: | 2002-11-25 02:47:57 |
Message-ID: | 1038192476.2847.4.camel@linda.lfix.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, 2002-11-25 at 02:28, Matthew Nuzum wrote:
> I have a table that has (among other things) two values, one named
> ftr_type and the other ftr_data.
>
> Depending on the value of ftr_type, ftr_data may contain the value of a
> primary key in another table. Because sometimes there is another table
> and sometimes there isn't, ftr_data is a varchar.
>
Why not make it integer but leave its value as NULL if there is no other
table?
Alternatively, cast it to text first:
junk=# select CAST('22'::text as int4);
int4
------
22
(1 row)
--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"Let us therefore come boldly unto the throne of grace,
that we may obtain mercy, and find grace to help in
time of need." Hebrews 4:16
From | Date | Subject | |
---|---|---|---|
Next Message | SUFFIAN RAMLI | 2002-11-25 04:24:39 | Insert bytea type into PostgreSQL |
Previous Message | Matthew Nuzum | 2002-11-25 02:28:11 | argh... can't cast varchar to int |