ADO.NET Provider for SAP SuccessFactors

Build 24.0.9062

テーブル

The 本製品 exposes tables for every entity set and singleton defined on the OData service document. Entities on these tables may be inserted, updated, or deleted using standard SQL insert, update, or delete statements.

Executing Deep Inserts with SQL

The 本製品 supports OData deep inserts, in which you simultaneously create a base entity and link it to related entities, by specifying navigation properties. To specify ナビゲーションプロパティ for an entity, you create a temporary table for the navigation property and then reference the temporary table in the insert to the base table. Reference the temporary table in the appropriate navigation property column on the base table. Each navigation property column is prefixed with the word "Linked".

Note that you must define the temporary tables and insert to the base entity within the same connection.

Example: Deep Inserts in SAP SuccessFactors

For example, consider the ExternalUser table. When creating an ExternalUser, you may also specify an ExtAddressInfo, ExtEmailInfo, ExtPersonalInfo, and ExtPhoneInfo. To do so, you can specify the following navigation properties.

Creating Temporary Tables

Insert the related entities into temporary tables that correspond to each navigation property. You can specify an existing entity's primary key or you can insert a new entity.

  • ExtAddressInfo: The following statement creates a new ExtAddressInfo:
    INSERT INTO ExtAddressInfo#TEMP (address1, city, country, zipCode) 
    VALUES ('123 Fake Street', 'Springfield', 'USA', '58008')
  • ExtEmailInfo: The following statements add two ExtEmailInfos to the ExternalUser:
    INSERT INTO ExtEmailInfo#TEMP (EmailAddress, EmailType, isPrimary) VALUES ('[email protected]', 'business', true)
    
    INSERT INTO ExtEmailInfo#TEMP (EmailAddress, EmailType, isPrimary) VALUES ('[email protected]', 'personal', false)
  • ExtPersonalInfo: The following statement specifies the existing ExtPersonalInfo:
    INSERT INTO ExtPersonalInfo#TEMP (personalInfoId) 
    VALUES (5)
  • ExtPhoneInfo: The following statement specifies the existing ExtPhoneInfo:
    INSERT INTO ExtPhoneInfo#TEMP (phoneInfoId) VALUES (3) 

The CData ADO.NET Provider for SAP SuccessFactors will assume that the ExtPhoneInfo and ExtPersonalInfo already exist and will only link to the existing references since only the primary keys were specified for either. When more than just the primary key is defined, such as the examples for ExtAddressInfo and ExtEmailInfo, the CData ADO.NET Provider for SAP SuccessFactors will attempt to create new entries - triggering the deep insert.

Inserting the Entity

In the INSERT statement for the base entity, reference the temporary tables in the LinkedExtAddressInfo, LinkedExtEmailInfo, LinkedExtPersonalInfo, and LinkedExtPhoneInfo columns:

INSERT INTO ExternalUser (password, productName, userId, userName, LinkedExtAddressInfo, LinkedExtEmailInfo, LinkedExtPersonalInfo, LinkedExtPhoneInfo) 
VALUES ('password', 'productname', 'newuserid', 'newusername', 'ExtAddressInfo#TEMP', 'ExtEmailInfo#TEMP', 'ExtPersonalInfo#TEMP', 'ExtPhoneInfo#TEMP')

Code Example

Below is the complete code to create the new ExternalUser:
ODataConnection odconn = new ODataConnection(connectionStr);
odconn.Open();

ODataCommand odcmd = new ODataCommand("INSERT INTO ExtAddressInfo#TEMP (address1, city, country, zipCode) VALUES ('123 Fake Street', 'Springfield', 'USA', '58008')", odconn);
odcmd.ExecuteNonQuery();

odcmd.CommandText = "INSERT INTO ExtEmailInfo#TEMP (EmailAddress, EmailType, isPrimary) VALUES ('[email protected]', 'business', true)";
odcmd.ExecuteNonQuery();

odcmd.CommandText = "INSERT INTO ExtEmailInfo#TEMP (EmailAddress, EmailType, isPrimary) VALUES ('[email protected]', 'personal', false)";
odcmd.ExecuteNonQuery();

odcmd.CommandText = "INSERT INTO ExtPersonalInfo#TEMP (personalInfoId) VALUES (5)";
odcmd.ExecuteNonQuery();

odcmd.CommandText = "INSERT INTO ExtPhoneInfo#TEMP (phoneInfoId) VALUES (3)";
odcmd.ExecuteNonQuery();

odcmd.CommandText = "INSERT INTO ExternalUser (password, productName, userId, userName, LinkedExtAddressInfo, LinkedExtEmailInfo, LinkedExtPersonalInfo, LinkedExtPhoneInfo) 
VALUES ('password', 'productname', 'newuserid', 'newusername', 'ExtAddressInfo#TEMP', 'ExtEmailInfo#TEMP', 'ExtPersonalInfo#TEMP', 'ExtPhoneInfo#TEMP')";
odcmd.ExecuteNonQuery();

odconn.Close();

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