Follow

Insert or Save Data

The Relational Save Data command allows you to insert and update records in the User Defined Relational Table.

NOTE: This command replaces Relational Insert, which has been deprecated

The Relational Save Data command requires the following arguments: Command, Realm, Password, Table, Data, Storage Type, and Subscriber identification.

api_web?r=myrealm&p=mypass&c=rdbsavedata&table=mytable&storageType=relational&subscriber_id=1232&data=mytable.myuniquekey,mytable.number,mytable.text^1232,89,My%20text

The command is 'rdbsavedata', the realm is 'myrealm', the password is 'mypass', and the table to insert data into is 'mytable' with data storage type 'relational' and the subscriber to insert or update has Subscriber ID of '1232'.  This command will insert a new row for the Subscriber defined or will update an existing row matching the Unique ID with the Subscriber defined.

To insert a new row, you must identify the Subscriber either by providing the subscriber id, customer key or email and first name.  The subscriber must already exist in the realm.  In addition, the Data block must include the unique key field defined for each table.

You can add one or many records with the same command.  To add multiple records, include additional data separated by the carat (^) character.  Each additional record must have the same number of data fields defined.

Example

Using all commands and arguments (please note the command is wrapped for display purposes only):

api_web?r=myrealm&p=mypass&c=rdbsavedata&table=pets&storageType=relational&subscriber_id=1232&data=pets.pet_id,pets.pet_type,pets.pet_name,pets.pet_breed^1232_01,cat,Chairman%20Meow,orange%20tabby^1232_02,cat,Mr.%20Cat,orange%20tabby

Successful results return:

SUCCESS: Total Records Processed: 2, Records Added: 2, Records Inserted: 2  

Results

The Relational Save Data command outputs either a SUCCESS or FAILURE message. 

Success

The Relational Save Data command success message returns the SUCCESS message.  The result format is:

SUCCESS: Total Records Processed: [number_data_sets_in_command], Records Added: [number_data_sets_added], Records Inserted: [number_new_rows_inserted]  

Failure

The Relational Save Data command will fail for several reasons, such as if the table does not exist.  The result format is:

FAILURE: [Reason]  

Arguments

The Relational Save Data command supports the following arguments:

Name

Req?

Description

Argument

Command

Yes

Defines the command to use.

cmd=rdbsavedata

c=rdbsavedata

Realm

Yes

Name of the realm to run the command.  This is required, and the command will fail if the realm and password do not match.

realm=[realm_name]

r=[realm_name]

Password

Yes

Authentication code for API access.  This is required, and the command will fail if the realm and password do not match.

pwd=[password]

p=[password]

Relational Table Name

Yes

Identifier of the relational data table in which to insert or update.

table=[table_name]

t=[table_name]

Data Storage Type

Yes

Type of data table in which to store data, currently only supports 'relational'.

This argument is CASE sensitive.  

storageType=relational

Subscriber Identification

Yes*

The subscriber must be uniquely identified by providing one of the following: 

  • subscriber_id
  • customer_key
  • email + first_name

Customer Key is required in realms in which Customer Key is enabled. 

First Name is not required if no duplicates exist in the realm.

*Added in v13.0.0, Subscriber optional if not an FK

subscriber_id=[subscriber_id]

customer_key=[customer_key]

email=[subscriber_email]

first=[first_name]

Data

Yes

Column related data.  At least one, unique field is required.   The name of each data field (column name) must be preceded by the table name in the format table_name.column_name.

The format is a list of comma separated field column names followed by one or more comma separated lists of column values separated by a carat (^).

data=[table_name.column_names^values]

d=[table_name.column_names^values]

d=[table_name.column_names^values^values]

Ignore Subscriber  

If importing data into a table that does not use Subscribers as the Foreign Key, then set the argument to Ignore Subscribers.  If enabled, you must also set the Table Type.

**Added in v13.0.0

ignore_subscriber=[0,1]

DEFAULT==0

Table Type  * If importing data into a table that does not use Subscribers as the Foreign Key, then set the Table Type to indicate which type of table the data is to be inserted: 
  • Flat
  • Regular
  • Join

**Added in v13.0.0

table_type=[flat]

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk