Inserting New Objects Using Batch Mode
This example demonstrates how to insert records into a class table and batch-update them to M-Files, including value list lookup and verification.
Review Target Table
SELECT * FROM MFCustomer;
View Lookup Values
SELECT mvli.*
FROM MFValueListItems mvli
INNER JOIN MFValueList mvl ON mvli.MFValueListID = mvl.id
WHERE mvli.Name = 'United Kingdom'
AND mvl.Name = 'Country';
Set Variable to Lookup
DECLARE @Country_ID INT;
SELECT @Country_ID = mvli.mfid
FROM MFValueListItems mvli
INNER JOIN MFValueList mvl ON mvli.MFValueListID = mvl.id
WHERE mvli.Name = 'United Kingdom'
AND mvl.Name = 'Country';
Insert New Record in Class Table
INSERT INTO dbo.MFCustomer (
Address_Line_1,
Address_Line_2,
City,
Country_ID,
Customer_Name,
Stateprovince,
Telephone_Number,
Web_Site,
Process_ID
)
VALUES (
'Building',
'Street Name',
'London',
@Country_ID,
'ABC Customer_2',
'Hampshire',
'090987098',
'www.abccompany.com',
1
);
Update Inserted Records from SQL into M-Files
EXEC spMFUpdateTable 'MFCustomer', 0;
Check Table
SELECT * FROM mfcustomer;