Re: Convert Char-->integer or Integer-->char
Posted in 2003
Topics: Performance & Tuning
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
Thank you very much,
I'll try this, this week
Bye
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