DB2/400 SQL : FullText

自古美人都是妖i 提交于 2019-12-26 04:55:10

问题


SQL DB2/400 : Is there somebody has tried to work wth FullText.

If i can have a sql exemple code, it will be great .

I would like, for exemple, to use it with a clob column.

Many thanks


回答1:


This pulls out all of space delimited words from mylib.myfile[mytext] and puts them into a table with two columns. I limit the word length to 15 cause really when do users type in words longer than 15 chars anyways and I've probably already found a match on the 1st 15 and presented a list to the user.

I copied this technique off the interweb.

CREATE TABLE mylib.myidx AS
(                                   
  WITH SPLITTER (ID, START, E, SECTION, ORIGINAL, NUM) AS 
  ( SELECT UID, 1, LOCATE(' ', mytext), CAST('' AS VARCHAR(8000)), mytext, 0  
      FROM mylib/myfile                                               
    UNION ALL
    SELECT ID, E + 1,
           CASE WHEN LOCATE(' ',ORIGINAL, E + 1) > 0
                THEN LOCATE(' ', ORIGINAL, E + 1)
                ELSE LENGTH(ORIGINAL) + 1
             END,
           SUBSTRING(ORIGINAL, START, E - START), 
           ORIGINAL, NUM + 1
      FROM SPLITTER
      WHERE E > START
  )                 
  SELECT ID AS UID                                                 
        ,CAST(SECTION AS VARCHAR(15)) AS SECTION                         
    FROM SPLITTER
    WHERE LENGTH(SECTION)>1                                 
)
WITH DATA;            


来源:https://stackoverflow.com/questions/55107368/db2-400-sql-fulltext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!