Re: Converting a number to Text
Posted in 2007
On Mon, 2007-07-30 at 17:29 +0100, Marco Greco wrote: > > chaboch wrote: > > Hi, > > > > I'm having a tough time with my SQL statement when I try to join two > > table. One table has a field named doc_no and is numeric while the > > other table has a field named record_key and is text. When i write > > "doc_no = record_key" and run the report, I get an error message about > > data types not being equal. > > > > How can I force the doc_no to be casted as text so I can join the > > tables? > > > > Please Help. Thank You, > > > > Chaim Bochner > > You are stuffed! text is a dumb blob type and there isn't much you can do with > it. Not even cast it. Not that it would help in this case, but text can be cast to clob. But as I said in my other reply, I doubt that record_key is actually of type "text." A certain business accounting product I know uses columns called doc_no and record_key. This could be a coincidence, of course, but if Chaim does use a related product, his record_key is a char(20)-column that contains numeric and non-numeric data. At any rate, "text" columns are terribly inadequate as keys, so no sane product would ever use "text" for a column called anything-key. > If you can make record_key a (say) lvarchar, or even a char (I am guessing > your text is not very long, if all you expect to do with it is to compare it > with integers), then you can join the two tables with no other requirement. ...unless the record_key column contains non-numeric data in addition to the sought numeric data. -- Carsten Haese http://informixdb.sourceforge.net