Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Victor, using Informix 7 with CSDK and PHP, tried joining an integer column to a char(30) column with CAST and :: and got error -201. Mladen Turk questioned the comma in the select list. Jonathan Leffler said IDS 7.x has no explicit casting (9.x does) and advised implicit conversion: intcol || '' for integer to char, or + 0 for char to integer.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
victor — — source: Usenet: comp.databases.informix
Hello,
I am a new bee with informix and I want to convert an integer to char or a
char to integer.
Informix 7+ CSDK + PHP
My problems is the attribute type is different. toto: type char(30) and titi
type integer but the data are the same (bad conception..)
I try :
select toto,titi
from table1,table2
where table1.titi=cast (table2.toto as integer)
---> error -201select toto,titi
from table1,table2
where table1.titi=table2.toto::integer
--> error -201
I couldn't modifiy my database. Have you got an idea ???
Thanks you very much for your help
↪ replying to victor
Mladen Turk — — source: Usenet: comp.databases.informix
"victor" wrote
> select toto,titi
> from table1,table2
> where table1.titi=cast (table2.toto as integer)>
> ---> error -201
>
> select toto,titi
> from table1,table2
> where table1.titi=table2.toto::integer>
> --> error -201
>
> I couldn't modifiy my database. Have you got an idea ???
> Thanks you very much for your help
>
why do you have comma in the select statement's toto,titi?
perhaps the following would help:
select toto.titi
from table1,table2
where table1.titi=table2.toto
MT?
↪ replying to Mladen Turk
victor — — source: Usenet: comp.databases.informix
Because I have an error :
toto is colomun type char(30)
and titi is annother column type integer
Bye
"Mladen Turk" <mturk_NOSPAM_@apache.org> a 'crit dans le message de
news:bqaqgo$un6$1@sunce.iskon.hr...
>
> "victor" wrote
>
> > select toto,titi
> > from table1,table2
> > where table1.titi=cast (table2.toto as integer)> >
> > ---> error -201
> >
> > select toto,titi
> > from table1,table2
> > where table1.titi=table2.toto::integer> >
> > --> error -201
> >
> > I couldn't modifiy my database. Have you got an idea ???
> > Thanks you very much for your help
> >
>
> why do you have comma in the select statement's toto,titi?
> perhaps the following would help:
>
> select toto.titi
> from table1,table2
> where table1.titi=table2.toto>
>
> MT?
>
>
victor wrote:
> I am a new bee with informix and I want to convert an integer to char or a
> char to integer.
> Informix 7+ CSDK + PHP
Informix Dynamic Server (IDS) 7.x does not support explicit casting.
Have you considered moving to IDS 9.x which does?
> My problems is the attribute type is different. toto: type char(30) and titi
> type integer but the data are the same (bad conception..)
> I try :
>
> select toto,titi
> from table1,table2
> where table1.titi=cast (table2.toto as integer)>
> ---> error -201
>
> select toto,titi
> from table1,table2
> where table1.titi=table2.toto::integer>
> --> error -201
>
> I couldn't modify my database.
Why not? It is badly broken in design. It needs an overhaul.
> Have you got an idea ???
As Mark Stock indicated, you can usually get an implicit conversion to
work. When you need an explicit conversion from INTEGER to CHAR, use
"intcol || ''", and when you need an explicit conversion from CHAR to
INTEGER use "+ 0". Note that if you have fancy formatting of your
CHAR values (such as leading zeroes), you should coerce to INTEGER
rather than to CHAR to avoid mis-formatting problems.
--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.