Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Location
    BRAZIL
    Posts
    10

    Question Unanswered: Argument in a function

    Is it possible to a function with a varchar argument to accept a number argument without having to use DIGITS function ?

    Eg.: col2 is integer type and the first argument is varchar type

    db2 => select emdd.lpad( col2, 20, ' ') from emdd.tb1
    SQL0440N No authorized routine named "LPAD" of type "FUNCTION" having compatible arguments was found. SQLSTATE=42884

    It just works when I enter:
    db2 => select emdd.lpad( digits(col2), 20, ' ') from emdd.tb1
    Silvana Meira

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    No, you must do one of two things.

    1) convert the argument to the correct type (as you did)
    2) write another UDF that performs the same task with the same name that accepts the other argument.

    DB2 does a "signature" search for executing functions. This means that the names AND the argument type must match for a function to work. This also allows for overloading a function (more than one function with the same name but different arguments). This is how option 2 works.

    HTH

    Andy

  3. #3
    Join Date
    Jan 2004
    Location
    BRAZIL
    Posts
    10

    Smile

    Thank you very much !!!!
    Silvana Meira

Posting Permissions

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