You can set M-Files to update any object type or a value list to and from an external database.
The example below describes how to define an object type to use an external database connection to SQL Server. The steps for specifying an external database connection for a value list are very similar.
SELECT CustomerNumber, CustomerName FROM Customer
SELECT ID, Name + ' ' + Department FROM Company
SELECT ID, Name, CustomerID FROM Contacts
SELECT * FROM Customer
If you want to... | Complete the following steps: |
---|---|
Allow read-only access | Do not check any of the check boxes and leave the statements empty. |
Allow users to update but not create or delete information |
|
Allow users to update, create, and delete information |
|
The table below explains of use the the four statements mentioned above.
Statement | Definition | Examples |
---|---|---|
UPDATE | When you edit an object in M-Files, M-Files Server edits the corresponding record in the external database using an UPDATE statement. Use a question mark (?) to signal columns to be updated. |
UPDATE Customers SET CustomerName = ? WHERE CustomerID = ? UPDATE Contact SET Name = ?, CustomerID = ? WHERE ContactID = ? |
INSERT INTO | When you create a new object in M-Files, M-Files Server adds a corresponding
record into the external database using an INSERT INTO statement. Use a
question mark (?) to indicate the value of each
column. Note: The INSERT INTO
statement input to M-Files
does not define a value for the ID column. The
database should be set up to automatically provide
an ID for new records. For example in SQL Server
databases, set the type of the ID column as
identity. In Access databases, use an AutoNumber type column for
IDs. Because Excel cannot produce new ID values, the
INSERT INTO statement
cannot be used with Excel.
|
INSERT INTO Customers( CustomerName ) VALUES( ? ) INSERT INTO ContactPersons( Name, CustomerID ) VALUES( ?, ? ) |
SELECT | After a new record has been created with the INSERT INTO statement, M-Files Server gets the ID of the newly created record with this SELECT statement. |
SELECT MAX( CustomerID ) FROM Customer |
DELETE | When you delete an object from M-Files, M-Files Server deletes the corresponding record in the external database using a DELETE statement. Use a question mark (?) for the ID of the record to be deleted. |
DELETE FROM Customers WHERE CustomerID = ? DELETE FROM Contacts WHERE ContactID = ? |