If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How to find the ASCII code of a Character

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-12-06, 07:37
Ravinandan Ravinandan is offline
Registered User
 
Join Date: Jul 2006
Posts: 3
How to find the ASCII code of a Character

Hi,
Is there any method or Built-In function which would help me to find the ASCII code of a Character or of a String(First character) in my SP.
I would appreciate if some one would give me the solution or point to where the solution can be found.

Thank's in Advance,
Ravinandan
Reply With Quote
  #2 (permalink)  
Old 07-12-06, 08:01
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Look in the SQL manual for the function ASCII.

Andy
Reply With Quote
  #3 (permalink)  
Old 07-12-06, 08:03
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,279
Try the
ASCII()
function.
__________________
With kind regards . . . . . SQL Server 2000/2005/2008/2008 R2 Earned beers: 16
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
Reply With Quote
  #4 (permalink)  
Old 07-12-06, 08:24
Ravinandan Ravinandan is offline
Registered User
 
Join Date: Jul 2006
Posts: 3
Thanks for quick response...

The ASCII() function worked....but strangely it is not present in the SQL manual.
The SQL manual from IBM site for DB2 Universal Database for iSeries SQL Reference V5R4(The database i'm using) doesn't have ASCII function in it's Built-In function's list.

Thanks once again.
Reply With Quote
  #5 (permalink)  
Old 07-12-06, 12:29
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
You can also cast the data as varchar (or char) for bit data.

SELECT SEX, CAST(SEX AS CHAR FOR BIT DATA) FROM EMPLOYEE FETCH FIRST 1 ROW ONLY

SEX 2
--- -----
F x'46'

You can also use SUBSTR to isolate a particular character in the string.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On