Re: Convert Char-->integer or Integer-->char
Posted in 2003
Hi Mark,
I have tried, but I have an error 1213. I think I am wrong somewhere.
Here is my tables :
Tables textos :
textos type
codigo char(30)
With codigo = 1, 15,20,34 etc...
Table Lots :
Lots type
lot integer
with lots.lot = 1,15,20,34 etc ...
I need this "request"
select textos.codigo from textos,lots where textos.codigo=lots.lot;This don't work it is normaly because type is different
So as you say I try this: select textos.codigo+0 from textos,lots where
textos.codigo=lots.lot
So I have an 1213 error --> A character to numeric conversion process
failed.
I try : select textos.codigo::INT from textos,lots where
textos.codigo=lots.lot
So I have an 201 error --> Syntaxe error as occurred
Have you got an explication ??
Thanks for your help.
Victor
"Mark D. Stock" <mdstock@mydassolutions.com> a 'crit dans le message de
news:bqb5lt$t7u$1@terabinaries.xmission.com...
>
> victor wrote:
>
> > 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 -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
>
> Have you tried:
>
> SELECT toto, titi
> FROM table1, table2
> WHERE table1.titi = table2.toto>
> The cast should be implicit in any version. Performance may not be
optimum,
> but that's down to your "bad conception". ;-)
>
> To return an INT value, use:
>
> SELECT toto+0, titi
>
> or
>
> SELECT toto::INT, titi
>
> Cheers,
> --
> Mark.
>
> +----------------------------------------------------------+-----------+
> | Mark D. Stock mailto:mdstock@MydasSolutions.com |//////// /|
> | Mydas Solutions Ltd http://MydasSolutions.com |///// / //|
> | +-----------------------------------+//// / ///|
> | |We value your comments, which have |/// / ////|
> | |been recorded and automatically |// / /////|
> | |emailed back to us for our records.|/ ////////|
> +----------------------+-----------------------------------+-----------+
>
> sending to informix-list