سؤال

I have a db2 function returning an integer. As per my limited knowledge the only way to see this function working is using to return column in a query like the example below.

Is there a way to display a return value of a function given a parameter withoyt building up a more complex query?

Example

I have a function

  myfoo(index integer) returns integer ...

And I am using it in a more complex quewry like

  select myIndex, myfoo(myIndex), myValue from MyTable...

If I try to get the following

  select from myfoo(3)

it will not work.

Is there any db2 function to print out the return value of that function without error?

هل كانت مفيدة؟

المحلول 2

If you have the compatibility vector, you can even use Oracle's Dual table. http://pic.dhe.ibm.com/infocenter/db2luw/v10r5/topic/com.ibm.db2.luw.apdv.porting.doc/doc/r0052874.html

Also, you can use the 'values' sentence. For example,

values myfoo(myIndex)

نصائح أخرى

SELECT myfoo(3) FROM SYSIBM.SYSDUMMY1

SYSIBM.SYSDUMMY1 is a special "dummy" table that contains a single row, the equivalent of Oracle's DUAL.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top