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 > Argument in a function

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-06-04, 09:45
Silvana.meira Silvana.meira is offline
Registered User
 
Join Date: Jan 2004
Location: BRAZIL
Posts: 10
Question 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
Reply With Quote
  #2 (permalink)  
Old 02-06-04, 10:53
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
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
Reply With Quote
  #3 (permalink)  
Old 02-06-04, 11:09
Silvana.meira Silvana.meira is offline
Registered User
 
Join Date: Jan 2004
Location: BRAZIL
Posts: 10
Smile

Thank you very much !!!!
__________________
Silvana Meira
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