Search code examples
sqlfunctionaggregatedefined

SQL: Agregate function for user defined type


I have user defined type:

create type indeks as integer

And question for my exam says: "Define aggregate function max for type indeks"

create function max(indeks)
returns indeks
source sysibm.max(integer);

Can you help me understand this? Because I know this is some elementary stuff.

create function max(indeks) 
returns indeks

These two lines are OK, I'm creating function and return type is also indeks.

source sysibm.max(integer);

But this is what I don't understand. I have no idea what is this line for.

Thanks in advance.


Solution

  • The schema name SYSIBM is used for built-in data types and built-in functions. The function source from the SYSIBM.MAX catalog table is merged into the statement. The built-in functions cannot simply be applied to User Defined Types. If they are required, then UDFs-based on the desired built-in functions must be generated. It means that you need to put this statement there

    source sysibm.max(integer);