• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

StartsWith function in DB2

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to find out the first letter in a word

like in java we have if(GOD.startsWith("G"))) then....

Is there a similar function in db2
 
Ranch Hand
Posts: 458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DB2 is a database not a programming language. I'm not aware of any built in search functions. You can define a field to be a substring of another field, but I don't think that's what you are looking for.

A SQL example on an i-series machine would look like this:
SELECT * FROM library/file WHERE upper(field) like 'G%'

Note: you do not need to use "upper", but if you do make sure your search value is in upper-case or you will never select any records.

Mid-rangeze file=table, field=column, record=row
[ October 14, 2004: Message edited by: Ray Marsh ]
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shan,
There is a substring function. This document lists string functions for different databases.

However, you should use the way Ray posted. It will perform queries faster and is more standard.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic