Contents
Environment & System Variables - Embedding Parameters in SQL Code

Preview Code That Uses Variables

After a SQL script that uses Environment Variables or System Variables is opened in the editor, you can preview the script with all variable values. To do so, open the script in the editor, right-click in the editor window, and select the option Combine Variables → Preview Script. A new window will then be opened where all variables in the script are replaced with the appropriate values.




Figure 102.15:  Selecting the Preview option to view the code.




Notes for Environment Variables:
1. If an editor window is connected to a database, Combine replaces the values of Environment Variables with the values specified for the Active Environment.
2. If an editor window is not connected to a database and no Container is selected for code execution in the Container drop-down (above the editor window), then as before, Combine replaces the value of Environment Variables with the values specified for the Active Environment.
3. If an editor window is not connected and a Container is selected for script execution, then Combine replaces the variables with the values specified for the Environment that contains the selected Container in the Container Manager.

Example: The following script contains two Environment Variables that are defined for the environment, namely LinkedServerName and TableOwner. This script also includes a variable called MyUndefinedVariable that is not defined for the environment. After selecting the Preview option (as demonstrated in the image above), the following window is opened in Combine. Here, Combine replaced <$LinkedServerName$> and <$TableOwner$> with the values specified for the environment, MyLinkedServer and dbo, respectively. Since the variable MyUndefinedVariable does not exist for this environment, it is therefore not replaced with a variable value.




Figure 102.16:  The previewed script where all variables are replaced with their values.





Notes for System Variables:
System Variables are replaced with their values in runtime, therefore the Preview functionality is only supported when working with connected windows in the editor. In other words, using the Preview feature with windows that are not connected to a single database will not show the values of System Variables.


© 2001-2017 JNetDirect, Inc. All Rights Reserved.