Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to find a single character field using sql query(DB2)

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
sambasivarao

New User


Joined: 10 Jul 2006
Posts: 47
Location: Bangalore

PostPosted: Sat Dec 16, 2006 1:32 am    Post subject: How to find a single character field using sql query(DB2)
Reply with quote

I have a table called NAME. In that table there is one field called FIRSTNAME. I want to retrieve the first name(field) which is has a single character ONLY.

Cheers,
Samba.
Back to top
View user's profile Send private message

DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Sat Dec 16, 2006 2:23 am    Post subject: Re: How to find a single character field using sql query(DB2
Reply with quote

This should get you closer:

Code:
SELECT *                           
  FROM NAME
 WHERE LENGTH(RTRIM(FIRSTNAME)) = 1



Dave
Back to top
View user's profile Send private message
sambasivarao

New User


Joined: 10 Jul 2006
Posts: 47
Location: Bangalore

PostPosted: Sat Dec 16, 2006 3:04 pm    Post subject: Re: How to find a single character field using sql query(DB2
Reply with quote

Thanks a lot David for quick response.

Cheers,
Samba.
Back to top
View user's profile Send private message
sambasivarao

New User


Joined: 10 Jul 2006
Posts: 47
Location: Bangalore

PostPosted: Mon Dec 18, 2006 2:39 pm    Post subject: Re: How to find a single character field using sql query(DB2
Reply with quote

Hi David,

Apart for this, any other options are there to get the single character of the field.

Thanks a lot in advance for your help.

Cheers,
Samba.
Back to top
View user's profile Send private message
vijju123

New User


Joined: 13 Dec 2006
Posts: 2
Location: delhi

PostPosted: Tue Dec 19, 2006 3:44 am    Post subject:
Reply with quote

Hai david...thanks for the answer ..would you please elaborate the query..that is..
WHERE LENGTH(RTRIM(FIRSTNAME)) = 1

what does RTRIM? STANDS FOR...

thanks in advance



cheers,
vijju.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Dec 19, 2006 3:52 am    Post subject: Re: How to find a single character field using sql query(DB2
Reply with quote

Hi vijju123,

It stands for Right TRIM. It trims, or removes blanks from the Right Side of the value, changing the length also.

Here's the link to the Manual


RTRIM
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts outrec field outside range Danielle.Filteau SYNCSORT 10 Sat Mar 04, 2017 2:37 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us