Hints and Tips Writing SQL Scripts
Previous Topic  Next Topic 

Since there is no interactive debugger in DMS for writing SQL scripts, you may want to us a third party tool to help you write the SQL.  There are many SQL tools available that enable you to write SQL and test the code against a live or test database.  If you would like to discuss writing SQL scripts with Dynafact, please feel free to give us a call.  (For your information, we use the third party tool Toad for SQL Server found at www.toad.com that also supports Oracle and other products.)


Once you have your SQL tool installed and connected to the database you want to import information from, the following is one method you can use to write the SQL:


  1. Open an SQL edit window in the SQL tool.
  2. Execute DMS and go to SQL script you want to create (for example, for Job Import SQL Scripts  select Import | Import Settings | Job Import SQL Scripts).
  3. Select New or Edit if you are editing to an existing SQL script.
  4. If there is more than one tab to define the SQL script, select the tab and type of the SQL script to define.
  5. Click on the button so that the required script information is displayed in the edit window.
  6. Highlight the created script and select mouse right click and Copy, or highlight the text and press the Ctrl + C keys to copy the script into the Windows clipboard.
  7. Paste the copied information in the clipboard into the opened SQL window of the third party tool you are using.  You can paste the clipboard information by the mouse right click and Paste, or Ctrl + V.
  8. At this point, you can Cancel the addition to the SQL Script in DMS if you wish.
  9. Work in the third party tool to perfect the SQL script using the structure copied from DMS.  Once you have it running the way you want and have verified the output, highlight the SQL script and copy it back into DMS in the appropriate tab and section of the SQL Script.
  10. Save the script in DMS.
  11. Test the SQL script by clicking on the button.  If you receive errors, close the test window, make the necessary changes, save the changes, and test the script again.


Repeat the above steps for each SQL script you want to write for the import.


For importing job if you are not using one or more import SQL scripts, make sure you leave the SQL scripts for these areas blank so the import knows to skip that area of import.   For example, if you do not have any Operation User Fields, the SQL script for Operation User Fields must be blank.  The DMS import utility knows that a blank SQL script means that there is nothing to import for that particular area of DMS.


Since you can write any number of SQL scripts you want, you may decide to have different scripts update different areas of DMS.  For example, you may have one script import all the job and operation information, but not the material details.  Once the material has been defined in the host system, you could have another script that imports just material detail.  For the material details import, the job SQL script and all other SQL scripts would be blank except for the Material Details SQL script.  On the Job SQL tab, just the Script Name and Connection Name would be defined.  Each script would then be executed as required by the users.