SELECT Table_1.ID, Table_1.F_Num FROM Table_1;
SQLExecDirect: SELECT "dbo"."Table_1"."ID" FROM "dbo"."Table_1" SQLPrepare: SELECT "ID","F_Num" FROM "dbo"."Table_1" WHERE "ID" = ? SQLExecute: (GOTO BOOKMARK) SQLPrepare: SELECT "ID","F_Num" FROM "dbo"."Table_1" WHERE "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? SQLExecute: (MULTI-ROW FETCH)
SQLExecDirect: SELECT "ID" ,"F_Num" FROM "dbo"."Table_1"並び替え/抽出がないので、特に見どころはない。Dynaset の場合、主キーの取得がまず実施される。それらを利用しレコードをフェッチしていくことになる。Snapshot の場合、すべてのレコードを取得する。
まず、並び替え:Order by
SELECT Table_1.ID, Table_1.F_Num FROM Table_1 ORDER BY Table_1.F_Num DESC;
SQLExecDirect: SELECT "dbo"."Table_1"."ID" FROM "dbo"."Table_1" ORDER BY "dbo"."Table_1"."F_Num" DESC SQLPrepare: SELECT "ID","F_Num" FROM "dbo"."Table_1" WHERE "ID" = ? SQLExecute: (GOTO BOOKMARK) SQLPrepare: SELECT "ID","F_Num" FROM "dbo"."Table_1" WHERE "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? SQLExecute: (MULTI-ROW FETCH)
SQLExecDirect: SELECT "ID" ,"F_Num" FROM "dbo"."Table_1" ORDER BY "dbo"."Table_1"."F_Num" DESC並び替え / Order by が指定されている場合、並び替えられたレコードを取得する。ACE でソートを実施していないということがわかる。
さて、抽出 / Where は気を付けたほうがよいポイントがあると思う。ODBC データソースである SQL Server でフィルタリングするか、すべてのレコードを取得してACEでフィルタリングするかという問題。
SELECT Table_1.ID, Table_1.F_Num FROM Table_1 WHERE Table_1.F_Num=10;
SQLExecDirect: SELECT "dbo"."Table_1"."ID" FROM "dbo"."Table_1" WHERE ("F_Num" = 10 ) SQLPrepare: SELECT "ID","F_Num" FROM "dbo"."Table_1" WHERE "ID" = ? SQLExecute: (GOTO BOOKMARK) SQLPrepare: SELECT "ID","F_Num" FROM "dbo"."Table_1" WHERE "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? SQLExecute: (MULTI-ROW FETCH)
SQLExecDirect: SELECT "ID" ,"F_Num" FROM "dbo"."Table_1" WHERE ("F_Num" = 10 )こういうのは問題なくフィルタリングされた情報のみ取得する。
SELECT Table_1.ID, Table_1.F_Text FROM Table_1 WHERE Table_1.F_Text Like '*a';
SQLExecDirect: SELECT "dbo"."Table_1"."ID" FROM "dbo"."Table_1" WHERE ("F_Text" LIKE '%a' ) SQLPrepare: SELECT "ID","F_Text" FROM "dbo"."Table_1" WHERE "ID" = ? SQLExecute: (GOTO BOOKMARK) SQLPrepare: SELECT "ID","F_Text" FROM "dbo"."Table_1" WHERE "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? SQLExecute: (MULTI-ROW FETCH)
SQLExecDirect: SELECT "ID" ,"F_Text" FROM "dbo"."Table_1" WHERE ("F_Text" LIKE '%a' )あいまい検索になるときワイルドカード文字が置き換えられてSQL Server 側で抽出されることもあるが、
SELECT Table_1.ID, Table_1.F_Date, Table_1.F_Text FROM Table_1 WHERE Table_1.F_Text Like 'B[ae]ll';
SQLExecDirect: SELECT "F_Text" ,"dbo"."Table_1"."ID" FROM "dbo"."Table_1" SQLPrepare: SELECT "ID","F_Date","F_Text" FROM "dbo"."Table_1" WHERE "ID" = ? SQLExecute: (GOTO BOOKMARK) SQLPrepare: SELECT "ID","F_Date","F_Text" FROM "dbo"."Table_1" WHERE "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? OR "ID" = ? SQLExecute: (MULTI-ROW FETCH)
SQLExecDirect: SELECT "ID" ,"F_Date" ,"F_Text" FROM "dbo"."Table_1"すべてのレコードを取得して ACE でフィルタリングすることがある。Dynaset の場合、主キーとフィルタに使用するフィールドを全レコード分取得し ACE でフィルタリング。そして、該当するレコードの主キーを使用してレコードを取得する動作になることがある。Snapshotの場合、まるっと全レコードを取得することになる。
0 件のコメント:
コメントを投稿