aspose file tools*
The moose likes JDBC and the fly likes StartsWith function in DB2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "StartsWith function in DB2" Watch "StartsWith function in DB2" New topic
Author

StartsWith function in DB2

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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
Ray Marsh
Ranch Hand

Joined: Jan 12, 2000
Posts: 458
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 ]

Anxiety does not empty tomorrow of its sorrows, but only empties today of its strength. – Charles Spurgeon
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29287
    
140

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: StartsWith function in DB2
 
Similar Threads
date calculation inside select clause
Result in XML format
How to Store Java Object to DB2 Database
Look up data from different databases
Dropping leading zeros on numeric field