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

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, textucsfile "..\\..\\doc\\takekurabe.txt", "ja+en"];
PreparedCommand "ins" [1, textucsfile "..\\..\\doc\\takekurabe.txt", "ja+de"];
PreparedCommand "ins" [2, textucsfile "..\\..\\doc\\takekurabe.txt", "ja"];
PreparedCommand "ins" [3, null, "ja+fr"];
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 L=?";
PreparedCommand "upd1" [textsjisfile "..\\..\\doc\\introduction.txt", "ja+de"];
PreparedCommand "upd1" [textsjisfile "..\\..\\doc\\kenpou.txt", "ja+en"];
PreparedCommand "upd1" [textsjisfile "..\\..\\doc\\KINGARTHURS_ROUNDTABLE.txt", "ja+fr"];
PreparedCommand "upd1" [null, "ja"];
ErasePreparedCommand "upd1";
Command "select N from T where C like ?" ["%の%"];

#update(2)
CreatePreparedCommand "upd2" "update T set (C,L)=(?,?) where L=?";
PreparedCommand "upd2" [textsjisfile "..\\..\\doc\\kenpou.txt", "en", "ja"];
PreparedCommand "upd2" [textsjisfile "..\\..\\doc\\rasyoumon.txt", "en", "ja+de"];
PreparedCommand "upd2" [textsjisfile "..\\..\\doc\\rasyoumon.txt", "ja", "ja+en"];
PreparedCommand "upd2" [textsjisfile "..\\..\\doc\\kenpou.txt", "ja", "ja+fr"];
ErasePreparedCommand "upd2";
Command "update T set L=? where L=?" ["ja+en", "en"];
Command "select N, L from T";
Command "select N from T where C like ?" ["%の%"];

#update(3)
Command "update T set C=? where C like ? and L=?" [null, "%行方%", "ja"];
Command "update T set L=? where C like ? and L=?" ["en", "%天皇%", "ja+en"];
Command "select N, L from T";
Command "select N from T where C like ?" ["%の%"];
Command "update T set (C,L)=(?,?) where C like ? and L=?" [null, "ja", "%下人%", "ja+en"];
Command "update T set L=? where C is null and L<>?" ["ja+en", "ja+en"];
Command "select N from T where C like ?" ["%の%"];
Command "verify index FTIndex cascade continue";

#delete(1)
Command "delete from T where N>=2";
#update(4)
Command "update T set C=? where N=0" [textsjisfile "..\\..\\doc\\hello.txt"];
Command "update T set L=? where C is not null" ["en"];
Command "update T set L=? where C is null" ["ja"];
Command "select N from T where C like ?" ["%の%"];

#update(5)
Command "update T set C=? where L=?" [textsjisfile "..\\..\\doc\\ricoh.txt", "ja"];
Command "select N from T where C like ?" ["%の%"];

#delete(2)
Command "delete from T where C like ? or L<>?" ["%リコー%", "ja"];
Command "select * from T";
Command "select count(*) from T";
Command "verify index FTIndex cascade continue";

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

TerminateSession;
Terminate;
End;

