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 > invoke udf through jdbc using input parameters

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-10-11, 12:10
mlybarger mlybarger is offline
Registered User
 
Join Date: Dec 2010
Posts: 8
invoke udf through jdbc using input parameters

i have a simple udf that i can invoke such as :

select doSomething('input 1', 'input 2', 'input 3') from sysibm.sysdummy1;

but i'd like to invoke this from java/jdbc passing input parameters.

the following :
select doSomething(?,?,?) from sysibm.sysdummy1;

gives a sql-418. i don't think that it likes the parameters in the select clause. any ideas on how i can do this?
Reply With Quote
  #2 (permalink)  
Old 01-10-11, 12:39
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
You need to cast the parameters to the correct data types so that DB2 can determine the UDF properly.

Andy
Reply With Quote
  #3 (permalink)  
Old 01-10-11, 13:37
mlybarger mlybarger is offline
Registered User
 
Join Date: Dec 2010
Posts: 8
thanks. it seemed silly to have to cast these, but it works.
Reply With Quote
  #4 (permalink)  
Old 01-10-11, 14:50
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
The reason you need to cast them is because DB2 allows you to have multiple UDFs with the same name (overloading). So in order for DB2 to know which UDF to use, you have to cast the parameters so it knows which one you want.

Andy
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