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 > RPAD equivalent in db2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-19-09, 09:29
tithisona tithisona is offline
Registered User
 
Join Date: May 2009
Posts: 1
RPAD equivalent in db2

i need to know the db2 equivalent query of the following:


RPAD( string,17,'X')
Reply With Quote
  #2 (permalink)  
Old 05-19-09, 12:30
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Maybe if you told us what it does. Also what DB2 version and OS.

Andy
Reply With Quote
  #3 (permalink)  
Old 05-19-09, 12:56
Stealth_DBA Stealth_DBA is offline
Registered User
 
Join Date: May 2009
Posts: 472
tithisona, if RPAD(string, 17,'X') means pad the string with 17 'X' to to the right, you might use:

string CONCAT REPEAT('X',17)
Reply With Quote
  #4 (permalink)  
Old 05-19-09, 14:05
norbertogf norbertogf is offline
Registered User
 
Join Date: Oct 2003
Location: Curitiba - PR - Brazil
Posts: 17
You coud create an UDF for that, as I do:

Code:
CREATE FUNCTION rpad(
    arg VARCHAR(4000), 
    pad VARCHAR(1), 
    len INTEGER) RETURNS VARCHAR(40)
SPECIFIC rpad
CONTAINS SQL
DETERMINISTIC
NO EXTERNAL ACTION
RETURN arg || REPEAT(pad, len - LENGTH(arg))
;
Hope it helps...
__________________
Norberto Gasparotto Filho

IBM Cert. DB2 v9 DBA
IBM Cert. DB2 v9 App. Developer
SCJP 5
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