Use the SQL Table-Valued Function if you do not need all of the search results, and if you do not have enough memory to use a cached index as used in the stored procedure search.
There are two SQL table-valued functions available, both called db2ext.textsearch. One of them has two additional parameters for use with the db2ext.highlight function.
db2 "select docid , author, score from TABLE(db2ext.textsearch('\"book\" ',
'DB2EXT','COMMENT',3,2,cast(NULL as integer))) as t, db2ext.texttab u
where u.docid = t.primkey"
The following are the
values you could return from the SQL Table-Valued Function: --> primKey <single primary key type>
the primary key
--> score DOUBLE
the score value of the found document
--> NbResults INTEGER
the total number of found results (same value for all rows)
--> numberOfMatches INTEGER
the number of hits in the document