ADO.NET Provider for Marketo

Build 25.0.9434

UPSERT ステートメント

UPSERT ステートメントは、既存のレコードを更新するか、既存のレコードが識別されない場合は新しいレコードを作成します。

UPSERT 構文

UPSERT 構文はINSERT 構文と同じです。Marketo はVALUES 句で指定された入力を使用して、レコードがすでに存在するかどうかを判断します。レコードが存在しない場合は、レコードの挿入に必要なすべてのカラムが指定される必要があります。テーブル固有の情報については、データモデル を参照してください。

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

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

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

C#

String connectionString = "URL=https://MyMarketoURL.mktorest.com/;OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;";
int rowsAffected;
using (MarketoConnection connection = new MarketoConnection(connectionString)) {
  MarketoCommand cmd = new MarketoCommand("UPSERT INTO Leads (Email) VALUES ('John')", connection);
  rowsAffected = cmd.ExecuteNonQuery();
}

VB.NET

Dim connectionString As [String] = "URL=https://MyMarketoURL.mktorest.com/;OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;"
Dim rowsAffected As [Integer]
Using connection As New MarketoConnection(connectionString)
  Dim cmd As New MarketoCommand("UPSERT INTO Leads (Email) VALUES ('John')", connection)
  rowsAffected = cmd.ExecuteNonQuery()
End Using

Copyright (c) 2025 CData Software, Inc. - All rights reserved.
Build 25.0.9434