Quote:
|
Originally Posted by sheela562
Can we write the table functions in SQL?If no,then How to write external tale functions in DB2 for Z/OS.
|
DB2/zos don't support table functions in SQL. It does support external table function.
The sql syntax is(please reference the SQL reference book for detail)
CREATE FUNCTION TUDFS(INPUT1 VARCHAR(1))
PARAMETER STYLE DB2SQL
FENCED
RETURNS TABLE (C1 DEC(5,0) ,
C2 VARCHAR(5),
C3 INT)
LANGUAGE PLI
DETERMINISTIC
NO SQL
EXTERNAL NAME "TUDFS"
SPECIFIC "TUDFS"
NO EXTERNAL ACTION
SCRATCHPAD 100
DBINFO
FINAL CALL
DISALLOW PARALLEL
WLM ENVIRONMENT WLMENV3
PROGRAM TYPE MAIN
CARDINALITY 30;
SELECT C1 FROM TABLE(TUDFS('A')) X ;
You still have to write your own application to support the table function. the above example will need an PLI application with name of 'TUDFS' to execute.
Just FYI, it is not easy to write an application for table function. Good luck.
nidm