dbQuery

Version 22.0.8473


dbQuery

Version 22.0.8473


データベースに対してクエリを実行します。

必要なパラメータ

  • driver:Java 版ではJDBC ドラーバーのクラス名、.NET 版ではADO.NET プロバイダー名。
  • conn:接続文字列、もしくはデータベースURL。
  • query:SQL クエリ文字列。

オプションのパラメータ

  • commandtimeout:CommandTimeout, in seconds, for the operation to complete.ゼロ(0)はタイムアウトなしを意味します。この属性のデフォルトは60です。デフォルト値は60です。
  • fromrow:開始からスキップする行数。デフォルト値は0です。
  • maxrows:データベースから返される行の最大数。-1 を設定すると、すべての結果が得られます。デフォルト値は-1です。
  • paramname#:The parameter names.
  • paramvalue#:The parameter values.
  • paramtype#:The parameter types.
  • transactionid: トランザクションのId。

Output Attributes

  • *:クエリによりアウトプットは異なります。

Example

The ArcScript sample below uses a Script Connector to execute a query against a SQLite database:

<arc:set attr="db.driver" value="System.Data.SQLite" />
<arc:set attr="db.conn" value="Data Source=C:\\Users\\JoeUser\\Documents\\SecretSanta_2021.db" />
<arc:set attr="db.query" value="SELECT * FROM Participants WHERE Name=@Name AND Email=@Email" />

<arc:set attr="db.paramname#1" value="Name" />
<arc:set attr="db.paramname#2" value="Email"/>
<arc:set attr="db.paramvalue#1" value="Joe" />
<arc:set attr="db.paramvalue#2" value="joeuser@cdata.com" />

<arc:call op="dbQuery" in="db" out="record">
  <arc:enum item="record">
    <arc:set attr="output.filename" value="[_attr] is [_value]" />
    <arc:push item="output" />
  </arc:enum>
</arc:call>

Once executed, the script outputs files indicating the values of each column for the matching records.