The following is a list of available functions you can write in a script.
Note that each function begins with wnsFunc_.
Function |
Name/Description/Parameters |
Function Name |
wnsFunc_AutoLogin |
Description |
Establishes a connection to a database. This should be the first function in your script This function takes three parameters in the following order: |
Parameters |
1.DSN name - This is either a DSN name or a connection string. 2.User ID - Login ID for the user. Set this value to a -1 if the first parameter is a connection string., 3.Password - Set this value to -1 if the first parameter is a connection string. |
Function Name |
wnsFunc_AutoTerminate |
Description |
Terminates WinSQL's process. This should be the last function in your script. Any script appearing after this function is ignored. If you skip this function, WinSQL will run the script and will display an empty window at the end. |
Parameters |
There are no parameters for this function. |
Function Name |
wnsFunc_DataDiff |
Description |
Runs the Data Diff wizard for the given template file. You must use the Data Diff Wizard in WinSQL and create a template before using this function. For more information, see the “Data Diff Wizard” topic in this document. |
Parameters |
Uses the name of the Data Diff template file name as the parameter. |
Function Name |
wnsFunc_ExportData |
Description |
Runs an export template. You must create an export template using WinSQL's GUI. For more information, see the “Using Export Templates” topic in this document. |
Parameters |
Expects one parameter, which is the name of a template file. For more information, see the “Using Export Templates” topic in this document. |
Function Name |
wnsFunc_ImportText |
Description |
Runs a text import template. You must create an import template using WInSQL's GUI. |
Parameters |
Expects one parameter, which is the name of a template file. For more information, see the “Importing Text Files” topic in this document. |
Function Name |
wnsFunc_HtmlExport |
Description |
Exports to HTML file(s) based on a template. You must create an HTML export template using WinSQL's GUI. For more information, see the “Using Export Templates” topic in this document. |
Parameters |
Expects one parameter, which is the name of a template file. |
Function Name |
wnsFunc_RunScript |
Description |
Runs any SQL script saved in a file. Multiple queries can be used, separated by a query separator. Uses two parameters in the following order. |
Parameters |
·SQL file name - Name of the file containing SQL queries. ·Output file name - This file will contain results from a SELECT queries and/or record affected count for DML and DDL queries. |
Function Name |
wnsFunc_SchemaDiff |
Description |
Runs schema diff wizard for the given template. You must create a Schema Diff template using WinSQL's GUI. Fore more information, see the “Schema Diff Wizard” topic in this document. |
Parameters |
Expects one parameter, which is the name of a template file. |
Function Name |
wnsFunc_SendStatusEmail |
Description |
Sends a status e-mail. This function is overloaded, meaning it can take either 2 parameters or 5 parameters, described as follows: |
Parameters |
Two Parameter Version: 1.E-mail option - This can either be 1, 2, or 3. If this value is 1, an e-mail is only sent when the status of every previous task is successful. If this value is 2, an e-mail is only sent when any of the previous tasks generates an error. When this value is 3, e-mail is sent regardless of the error status. 1.Attachments - Name of the file(s) to be attached. Multiple file names can be attached, separated by three pipe characters (|||). You can use $FILE_ATTACHMENTS string as the name of a file if the file name should be determined from the previous script. For example, when you run an Export template to a text file, the name of the output file is read at run time. Refer to the script samples following this table. Note: This function obtains the recipient and sender e-mail addresses from the WinSQL global configuration, which can be set by selecting Options from the Edit menu in WinSQL. Five Parameter Version: 1.E-mail option - same as above 2.Attachment - same as above 3.Recipient – E-mail address of the recipient. Multiple addresses can be added, separated by a comma. 4.Sender name - Name of the sender 5.Sender e-mail – E-mail address of the sender Note: In either parameter version, the body of the e-mail is generated by WinSQL and is based on the tasks that are run prior to calling this function. |
Function Name |
wnsFunc_ExportDataBag |
Description |
Exports data stored in a Databag to a table, This method takes 5 parameters in the following order. |
Parameters |
1.Databag File name 2.Target DSN 3.User ID for the connection 4.Password for the connection 5.Target table name |
Function Name |
wnsFunc_SwitchDatabase |
Description |
Switches the connection context to a different database. This function is only meaningful when your back-end database supports this concept. For example, Microsoft SQL Server and Sybase support switching to a different database, but Oracle does not. |
Parameters |
Takes one parameter containing the desired database name. |