User defined function in SELECT-WHERE statement



IBM's flagship relational database management system

User defined function in SELECT-WHERE statement

Postby coboler » Tue Dec 16, 2008 3:51 pm

Hi all,

I have a problem with the syntaxis to use a UDF in an SQL:
- I have created an UDF which delivers a number.
- I would like to use this number for a condition in the WHERE option of a SELECT statement.

I would like to do this:

Function defined -->
db.function(date)=number

SQL statement -->
select *
from table
where column_of_table = db.function(date)

Actually, it is a bit more complicated, but I would like to know if this is what I am doing wrong...

Thanks!
coboler
 
Posts: 3
Joined: Fri Oct 31, 2008 2:11 pm
Has thanked: 0 time
Been thanked: 0 time

Re: User defined function in SELECT-WHERE statement

Postby dick scherrer » Tue Dec 16, 2008 7:18 pm

Hello,

Issue the function and retrieve the number to a host variable.

Use the host variable in the sql.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: User defined function in SELECT-WHERE statement

Postby coboler » Tue Dec 16, 2008 7:50 pm

I could finally fix it in the way I was doing.
Anyway, thanks for your answer Dirk!!
coboler
 
Posts: 3
Joined: Fri Oct 31, 2008 2:11 pm
Has thanked: 0 time
Been thanked: 0 time

Re: User defined function in SELECT-WHERE statement

Postby dick scherrer » Wed Dec 17, 2008 6:13 am

Hello,

Good to hear it is working :)

If you post how you fixed the problem, it will probably help someone else who encounters the same situation.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post