Pasing Distinct values to UDFs in SQLRPGLE

20 pts.
Tags:
AS 400
SQLRPGLE
Hi,
I need to execute a query like,
select UDF(col2) from FILE. 
 
col2 is not a unique field in FILE. I don't want to calculate UDF(col2) for same values. 
FILE
col1 col2
1      77
2      77
3       85
4       85
5       52
I need to handle this situation in query itself.
Kindly help me in resolving this problem.
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

You could try wrapping it around another select like

select DISTINCT col2 from file 
group by col 2

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • TheRealRaven
    You showed some sample data. Can you please show what result you expect? We need to know what's expected or desired. Also, what value will supplied to the UDF and what is its data type?

    Especially, what is the UDF's definition?
    35,120 pointsBadges:
    report
  • GregManzo
    Using 'select distinct' as suggested by Todd should work. Also be aware that you can define your UDF as 'deterministic' - this will cause SQL to _not_ call your function for same input values but just cache the result. ie. if your function was to calculate Pi, it would only be called once and SQL will continue to use the same result for all subsequent rows.
    2,960 pointsBadges:
    report
  • TheRealRaven
    SELECT DISTINCT will work if you need to know about retrieving distinct values as a single row. But if you're actually asking about passing possible distinct values, the question needs to be clarified.
    35,120 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: