Link to home
Start Free TrialLog in
Avatar of zephyr_hex (Megan)
zephyr_hex (Megan)Flag for United States of America

asked on

Informix SQL : select distinct and text field

In Informix, is there a way to convert or cast a text field so that i am able to SELECT DISTINCT ?
Avatar of Pavel Celba
Pavel Celba
Flag of Czechia image

You should convert the text to lvarchar:

SELECT DISTINCT CAST(YourTextColumn AS LVARCHAR(10000)) ...

It is not obvious to select distinct records this way. Better solution is to calculate some checksum from TEXT column and then select distinct based on this checksum.
Avatar of zephyr_hex (Megan)

ASKER

before i posted, i tried cast(mytextfield as varchar(255))

i tried your suggestion, and i'm still getting the same message:  No cast from text to lvarchar.
Another option should be:

SELECT DISTINCT substr(text,1,length(text)) ...
If above solution fails, then you cannot SELECT DISTINCT from text column and the only solution is to write/find out some checksum function.
can you provide an example of how the checksum would work?

also... does Informix just not allow that type of conversion?  i can do it in SQL 2005.
ASKER CERTIFIED SOLUTION
Avatar of Pavel Celba
Pavel Celba
Flag of Czechia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial