SQL statement example 4
In a
simple_insert_with_parameters
thread, a file is read
with this structure:
John, Smith, 2014
The record is not added to the database. This is what displays in the test console:
CALL: INSERT INTO patients(patients.fname, patients.lname, patients.DOB) VALUES
(patients.fname, patients.lname, patients.DOB)
Testing Tool result:
Test with MESSAGE 1
John,Smith,2014
Running DB Write action succeeded.
The SQL run result:
INSERT INTO patients(patients.fname, patients.lname, patients.DOB) VALUES (Smith, 2014, )
In this case, the first value, patients.fname
, is missing and there is a comma at the end of the statement.
In this example, the input message does not match the database schema
format defined in the
simple_insert_with_parameters
thread.
The input message is:
John, Smith, 2014
The databases schema format (patients
) is:
id, fname, lname, DOB
Because there is no DOB field given in the message, at runtime:
- patients.fname is replaced with “
Smith
". - patients.lname is replaced with “
2014
". - patients.DOB is replaced with “”.
You can input a full message such as “idValue,
John, Smith, 2014
.”
You can also specify a message with an empty “id
.” For example, “, John, Smith, 2014
.”