# lang情報のついた全文索引のテスト(scalar, fixed lang)

Begin;
Initialize;
InitializeSession "DefaultDB";

# 表を作成
Command "create table T (N int, C ntext, L language)";
Command "create index T_I on T(N)";

# 索引作成
Command "create fulltext index FTIndex on T(C) language column L hint 'inverted=(normalized=true, indexing=dual, tokenizer=DUAL:JAP:ALL:1 @NORMRSCID:1 @UNARSCID:1)'";

#insert
CreatePreparedCommand "ins" "insert into T (N, C, L) values (?, ?, ?)";
PreparedCommand "ins" [0, textsjisfile "..\\..\\doc\\introduction.txt", "ja+en"];
PreparedCommand "ins" [1, textsjisfile "..\\..\\doc\\kenpou.txt", "ja+en"];
PreparedCommand "ins" [2, textsjisfile "..\\..\\doc\\rasyoumon.txt", "ja+en"];
PreparedCommand "ins" [3, null, "ja+en"];
ErasePreparedCommand "ins";

Command "select N from T where L=?" ["ja+en"];
Command "select N from T where C like ?" ["%の%"];
# verify
Command "verify index FTIndex cascade continue";

#update(1)
CreatePreparedCommand "upd1" "update T set C=? where N=?";
PreparedCommand "upd1" [textsjisfile "..\\..\\doc\\kenpou.txt", 0];
PreparedCommand "upd1" [null, 1];
PreparedCommand "upd1" [textsjisfile "..\\..\\doc\\KINGARTHURS_ROUNDTABLE.txt", 2];
PreparedCommand "upd1" [textsjisfile "..\\..\\doc\\introduction.txt", 3];
Command "select N from T where C like ?" ["%の%"];

#update(2)
CreatePreparedCommand "upd2" "update T set C=? where C like ?";
PreparedCommand "upd2" [null, "%最高裁判所%"];
PreparedCommand "upd2" [null, "%打率%"];
PreparedCommand "upd2" [textsjisfile "..\\..\\doc\\KINGARTHURS_ROUNDTABLE.txt", "%老婆%"];
PreparedCommand "upd2" [textsjisfile "..\\..\\doc\\RainyNight.txt", "%ディレクトリ%"];
ErasePreparedCommand "upd2";
Command "select N from T where C like ?" ["%の%"];
Command "verify index FTIndex cascade continue";

#update(3)
Command "update T set C=? where C is not null" [null];
Command "select N from T where C like ?" ["%の%"];
Command "verify index FTIndex cascade continue";

#delete(1)
Command "delete from T where N=3";
#update(4)
PreparedCommand "upd1" [textsjisfile "..\\..\\doc\\introduction.txt", 2];
Command "update T set C=? where C is null" [textsjisfile "..\\..\\doc\\kenpou.txt"];
Command "select N from T where C like ?" ["%の%"];

#delete(2)
Command "delete from T where C like ?" ["%解散%"];
#update(5)
PreparedCommand "upd1" [textsjisfile "..\\..\\doc\\RainyNight.txt", 1];
Command "select N from T where C like ?" ["%の%"];
ErasePreparedCommand "upd1";

#delete(3)
Command "delete from T where L=?" ["ja+en"];
Command "select count(*) from T";
Command "verify index FTIndex cascade continue";

# 全文ファイルテスト用の表を消去
Command "drop table T";

TerminateSession;
Terminate;
End;

