Re: SQL Question???
Posted in 1995
> rob@dssmktg.com (Robert Minter) writes:
>
> I get a -305 error using 4.10 Informix:
>
> 305: Subscripted column (num1) is not of type CHAR, VARCHAR, TEXT nor BYTES
Of course a subscript can't refer to a numeric type field. Inside the database
numerics are binary data and a subscript isn't very meaningfull.
> Richard Thomas writes:
> * What's wrong with:
> * select * from tab1 where column1[4,5] = "87"
> *
> * Simple :-)
> *
> * I'll admit I've never heard of "mod", but the above
> * solution works fine for me!
Your column1 will have to be defined as char(xx) (or varchar) for this to
work.
You can of course put a numeric value into a char field. In many cases
that may work ok, and solve your problem. You will of course have to
make sure you allways right justify your numbers within the char-field.
> * } From: proberts@lynx.informix.com (Paul Roberts)
> * } In article <463ihb$q72@ixnews7.ix.netcom.com>,
> * } Mark Truty <marktrut@ix.netcom.com> wrote:
> * } >
> * } >I am trying to do a SQL query on a numeric field.
> * } >How do I query the last 2 numbers of a 5 digit field?
> * } >Example: number field = 54387 - I want to search for all records that
> * } >end in 87.
> * } >Thanks
> * } I really feel that we ought to be able to say:
> * } select *
> * } from tab1
> * } where column1 mod 100 = 87
mod is in ver. 7.10 OnLine. You say:
where mod(column1,100) = 87
i think. I didn't try, but it looks like this in the manual.
> * } But last time I looked, the "mod" function was available in 4GL but
> * } not in SQL.
> * }
> * ) [horribly clunky solution deleted]
As Malcolm Weallans writes you should realy think through your database
design when this has become neccessary, but sometimes it may be..
Nils.Myklebust@ccmail.telemax.no
NM-data, Dalsbergstien 7, N-0170 Oslo, Norway
My opinions are those of my company