The Job Import SQL Scripts are where you define the SQL to import jobs from an external database into DMS. Before you add the SQL scripts, one or more connection strings must be defined. Any number of SQL import scripts can be defined. For help writing SQL scripts in DMS, please see Hints and Tips Writing SQL Scripts. Once you have completed and tested the scripts, Job Import via SQL is used to run the script.
To define job importing SQL scripts, select Interface | Import settings | Job Import SQL Scripts.
A window will appear with the current list of defined job import SQL scripts in the tree. The example below shows an empty list of SQL scripts in the tree:
The following tabs and commands are:
File
The job import SQL script has two tabs; the Job SQL tab where you define the name of the SQL script, the connection name and the SQL to retrieve job header information, and the Other SQL tab where you define the following job information:
If you do not use one of the above SQL definitions, leave the SQL script for these areas blank. DMS ignores blank SQL scripts.
Note that for each SQL script, the following SQL Order By clause is recommended to ensure the data is imported correctly:
The job tab requires three entries:
In order to help you build the SQL script DMS provides a button that adds the necessary information for you to add your custom information to. Click on the button, DMS will ask you to verify that you want to add the required SQL fields to the script. If you select yes, DMS adds the SQL script as in the example below:
To the above script you would add the parameters required to complete the SQL. For example, for each value after the “as” enter the name of the column or calculated field from the source database. You also need to add the table(s) to the “From” statement, any joins, and any required information to the “where” clause. Note that the yellow line after the lines numbers indicates lines that have been edited. Once the save button has been selected, the yellow line will disappear.
Once a script has been entered, you can test the script by using the button. This button will run the script and access the external database. Depending on the number of rows selected, the test may take a few minutes to execute. After the test, press the close button to close the test window.
If an error occurs, such as a missing column of required information, the test will display the error in a window. Close the test window and make the changes to the script as required.
The example below shows the Other SQL tab window:
The Other SQL tab requires the following information:
Depending on the Script Type selected, pressing the will add the necessary SQL information for you to customize. The example below shows the Material Details script when the Build SQL button has been pressed:
Note that for user fields you must enter the number of user fields that will be imported. For example, if you have three job user fields to be imported, enter 3 to the Number of User Fields. DMS will build the corresponding SQL as follows:
The following is an example of importing three user fields using SQL from and external database table called ExternalJobTbl. The MapNo must match the DMS user field map reference numbers as defined by User Fields Required. In the example below, a customer, drawing number, and engineer name are being added to the DMS user fields with map reference numbers 1, 2, and 3:
Once a script has been entered, you can test the script by using the button. This button will run the script and access the external database. Depending on the number of rows selected, the test may take a few minutes to execute. After the test, press the close button to close the test window.
If an error occurs, such as a missing column of required information, the test will display the error in a window. Close the test window and make the changes to the script as required.
Please note that the test does not validate that the information coming in from an external database is correct. Rather, it is verifying that the SQL script structure is correct and the external database can be accessed.