Why use ajMergeRec?
The ajMergeRec function update records in databases if it exists. Otherwise, it’ll create a new record.
Imagine you need to update your databases, but you have the below scenarios:
New records that are not in your database.
Records that are in your database but there are changes in value that need to be updated.
No specific information on which data needs to be updated or which data needs to be created.
In a standard scenario, you will need to create 2 different statements using the ajCreateRec and ajUpdateRec. You will also need to perform checks on the database before running either of the function to know which function to run.
However, ajMergeRec function enables you to use a single statement to run the entire process. It’ll update the records if it exists otherwise, it’ll create a new record.
The below shows you how ajMergeRecord syntax works.
ajMergeRec( table_name, column_headers, data, table_schema, [data_source_id], [run_condition], [run_by_function_point_only] )
For more information, click here.
Download our Community Edition from this link and try it yourself today.