Hi,
is there a way to force db2 to invoke a user defined sql function in the select list of a select statement once per row returned by that select?
I have an udf like that:
create function nextid()
returns decimal(10)
language sql
not deterministic
external action
reads sql data
begin atomic
declare v_id decimal(10);
set v_id = next value for sys_objektid_seq;
return v_id;
end
(In reality that function contains some more lines to return a modified id, but the problem can be produced with this one).
The following statement
select nextid() from sysbed
where sysbed is a table with more than one row. The result of that select contains one row per row in the table, but the column value is the same in all lines. Executing the same statement again shows that the function has been invoked only once for the complete statement and not once per row (directly using next value for .... in the select list will return a new value per row).
I've allready tried modified function definitions (no external action and/or not deterministic) but that has not helped.
Any ideas to solve that without using a (java) external function (which is bad because in that case we had to deploy more than just sql scripts)? We are using DB2 8.2 Express Edition.
Holger Schlegel