在下列情况下使用“SQL 表值函数”:实现了接口,但是不需要返回所有结果,或者没有使用存储过程接口所需要的所有实际内存。
提供了两个 SQL 表值函数,它们都称为 db2ext.textsearch。一个函数具有与 db2ext.highlight 函数配合使用的附加参数。有关进一步的信息,请参阅使用 HIGHLIGHT 函数。
“SQL 表值函数”提供了与存储过程相同的游标界面来仅获取部分结果。但是,仍然需要将结果与用户表连接起来。可以在以下示例中了解这种情况:
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"
下面是一些可能从“SQL 表值函数”返回的值:
--> 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
注意,只允许存在单个主键列。有关这些参数进一步的详细信息,请参阅 DB2EXT.TEXTSEARCH。