Results 1 to 4 of 4
  1. #1
    Join Date
    May 2009
    Posts
    1

    Unanswered: RPAD equivalent in db2

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


    RPAD( string,17,'X')

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Maybe if you told us what it does. Also what DB2 version and OS.

    Andy

  3. #3
    Join Date
    May 2009
    Posts
    508
    Provided Answers: 1
    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)

  4. #4
    Join Date
    Oct 2003
    Location
    Curitiba - PR - Brazil
    Posts
    18
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •