Sample Scripts

Example 1

This script run SQL scripts saved in a file named BackupDB.sql.

-- Establishes connection to a database.The DSN name is 'testData' 
-- User id is scott and tiger is the password 
wnsFunc_AutoLogin("testData", "scott", "tiger")

 

-- Switch the database to a different value 
wnsFunc_SwitchDatabase("Northwind") 

-- Following function will run the scripts in BackupDB.sql file 
-- Output logs are saved to BackupDB.out file 
wnsFunc_RunScript("C:\data\BackupDB.sql", "C:\data\BackupDB.out") 

-- Send status email if the script fails or succeeds 
wnsFunc_SendStatusEmail("3", "C:\data\BackupDB.out") 

-- Terminate WinSQL 
wnsFunc_AutoTerminate()

Assuming the above script in saved in a file named TestScript.wxf, the following command will execute the script:

c:\Program Files\Synametrics Technologies\WinSQL\winsql "c:\data\TestScript.wxf"

 

Example 2

This script runs an export template that exports data from a table to a text file. The name of the generated text file is automatically read from the export template and is attached to the e-mail. This is done by specifying $FILE_ATTACHMENTS as a file name in wnsFunc_SendStatusEmail function.

Of important note in this example is the fact that you do not have to call the wnsFunc_AutoLogin function. This is because the connection parameters are specified in the export template file, which is 24Hour.wet in this case.

 

-- Execute export routine
wnsFunc_ExportData("C:\data\24Hour.wet") 

-- Send status email 
wnsFunc_SendStatusEmail("3", "$FILE_ATTACHMENTS") 

-- Finally terminate WinSQL 
wnsFunc_AutoTerminate()