I would like to see the code for a function defined like below. This function -lives in a schema called MYSCHEMA -makes usage of a shared library installed.

I tried to use the following but it doesn't work.

  select r.routinename as FunctionName, r.text as FunctionBody from 
  syscat.routines r where r.origin in ('U','R') and ROUTINESCHEMA='TRADE' 
  AND ROUTINETYPE ='F'

How can I do that?

   create or replace function MyFunction(varchar(60))
          returns  table(
          ..fields..
           )
          external name 'mySharedLib.so!function'
          language c
          parameter style sql
有帮助吗?

解决方案

There's no "code", just the function definition. You can either use db2look or generate the definition yourself by querying the system catalog views SYSCAT.ROUTINES and SYSCAT.ROUTINEPARMS.

其他提示

DB2 will not store the code of the external routines (C or Java). DB2 will just call the external binary when the function or SP is called. If the DB cannot locate the binary, it will throw an error

However, the mapping between a routine definition and the called binary is in the catalog, where DB2 will store the header and which binary has to call.

When you add a routine, DB2 does not even check it that routine has the good format, or callable parameters. That will be done at execution time.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top