select on string_length - x don't work, please help!
Posted in 1999
Topics: General Discussion
hi i want to cut off the last 5 chars from each field, but it don't work: SELECT field1[1,LENGTH(field1)-5] FROM table1 any idea i could do this? (each field have a different length) cu Fasi
Try the SUBSTRING function: SELECT SUBSTRING(field1 FROM 1 FOR LENGTH(field1) - 5) FROM table1; The implicit substring function (i.e., square brackets) does not accept variables or mathematical f unctions. Fasi wrote: > hi > > i want to cut off the last 5 chars from each field, but it don't work: > > SELECT field1[1,LENGTH(field1)-5] FROM table1 > > any idea i could do this? (each field have a different length) > > cu > Fasi -- Richard C. Auslander Database Manager AirFlash, Inc. 1733 Woodside Rd., Suite #110 Redwood City, CA 94061 (650) 556-7928 www.airflash.com
I always get: Major error code: -201 [VENDORLIB] Vendor Library Error: A syntax error has occurred. i use Informix Universal-Server version 9.1, is the SUBSTRING function avalible in this version, because i don't find it the tutorial. or do i have to write the SUBSTRING function first? thnx Fasi > Try the SUBSTRING function: > > SELECT SUBSTRING(field1 FROM 1 FOR LENGTH(field1) - 5) FROM table1; > > The implicit substring function (i.e., square brackets) does not accept > variables or mathematical f unctions. > > Fasi wrote: > > > hi > > > > i want to cut off the last 5 chars from each field, but it don't work: > > > > SELECT field1[1,LENGTH(field1)-5] FROM table1 > > > > any idea i could do this? (each field have a different length) > > > > cu > > Fasi > > -- > Richard C. Auslander > Database Manager > > AirFlash, Inc. > 1733 Woodside Rd., Suite #110 > Redwood City, CA 94061 > (650) 556-7928 > > www.airflash.com > >