Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.Opens in a new tab

For information on migrating to InterSystems IRISOpens in a new tab, see Why Migrate to InterSystems IRIS?

簡単なクエリ

パラメータを使用しない SQL コマンドを実行する場合は、CacheCommand を使用するだけで済みます。CacheDataReader を使用すると、クエリから返されるデータのストリームに対して、非常に効率的な順方向のアクセスおよび読み取り専用のアクセスを実行できます。以下のメソッドでは、CacheCommandCacheDataReader を使用して、データベース内の “Business” の連絡先をすべて取得し、表示しています。


public void DisplayBusinessContacts()
{
try{
    string sql = 
      "Select %ID, Name, ContactType From Provider.Contact Where +
                             "ContactType %startswith 'Business' Order By Name";

    CacheCommand command = new CacheCommand(sql, cnCache);
    CacheDataReader reader = command.ExecuteReader();
    while (reader.Read())
    {
       Console.WriteLine("ID: {0} Name: {1}", reader[reader.GetOrdinal("ID")], 
                                            reader[reader.GetOrdinal("Name")]);
    }  
  }
catch (CacheException e){}
}

cnCache は、開いている CacheConnection インスタンスを表します。

FeedbackOpens in a new tab