ADO.NET Provider for IBM Cloud Data Engine

Build 23.0.8839

INSERT ステートメント

新しいレコードを作成するには、INSERT ステートメントを使用します。

INSERT 構文

INSERT ステートメントは、挿入するカラムと新しいカラム値を指定します。複数のカラム値は、次の例に示すように、VALUES 句のカンマ区切りリストで指定できます。

INSERT INTO <table_name> 
( <column_reference> [ , ... ] )
VALUES 
( { <expression> | NULL } [ , ... ] ) 
  

<expression> ::=
  | @ <parameter> 
  | ?
  | <literal>

次の例に示すように、ExecuteNonQuery メソッドを使って、データ操作コマンドを実行し影響を受けた行を取得できます。

C#

String connectionString = "Api Key=MyAPIKey;";
using (IBMCloudSQLQueryConnection connection = new IBMCloudSQLQueryConnection(connectionString)) {
  int rowsAffected;
  IBMCloudSQLQueryCommand cmd = new IBMCloudSQLQueryCommand("INSERT INTO [CloudObjectStorage_1].[SampleBucket_1].Jobs (Status) VALUES ('John')", connection);
  rowsAffected = cmd.ExecuteNonQuery();
}

VB.NET

Dim connectionString As [String] = "Api Key=MyAPIKey;"
Using connection As New IBMCloudSQLQueryConnection(connectionString)
  Dim rowsAffected As Integer
  Dim cmd As New IBMCloudSQLQueryCommand("INSERT INTO [CloudObjectStorage_1].[SampleBucket_1].Jobs (Status) VALUES ('John')", connection)
  rowsAffected = cmd.ExecuteNonQuery()
End Using

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 23.0.8839