This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
bw2:sql_command_tool [2020/12/15 12:18] akoehler [Related Documents] |
bw2:sql_command_tool [2023/12/29 14:09] (current) wgates [Reader (SQL Server and HANA)] |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Introduction (SQLCommand | + | ====== Introduction (SQL/ |
| This document describes the use of the Bizweaver SQL Command tool. | This document describes the use of the Bizweaver SQL Command tool. | ||
| Line 14: | Line 14: | ||
| ====== Related Documents ====== | ====== Related Documents ====== | ||
| - | The following pages contain additional information that may be helpful with the development of Bizweaver workflows using the SQLCommand tool. | + | The following pages contain additional information that may help develop |
| * **[[bw2: | * **[[bw2: | ||
| Line 28: | Line 28: | ||
| ====== Basic Tool Setup ====== | ====== Basic Tool Setup ====== | ||
| - | {{ :bw:sqlimage1.png? | + | {{ :bw2:bizweaversqltool1.png |}} |
| - **Connection** Sets a connection to a database is selected from the drop-down list. | - **Connection** Sets a connection to a database is selected from the drop-down list. | ||
| Line 51: | Line 51: | ||
| Only the **Reader** function is supported for HANA databases at this time. | Only the **Reader** function is supported for HANA databases at this time. | ||
| - | Standard SQL Server or HANA syntax is used for the commands. The basic syntax of the SQL statement is validated when the [**OK**] button is clicked. If the statement is not valid an error message is displayed but the step is saved as-is | + | Standard SQL Server or HANA syntax is used for the commands. The SQL statement's basic syntax |
| ===== Reader (SQL Server and HANA) ===== | ===== Reader (SQL Server and HANA) ===== | ||
| Line 59: | Line 59: | ||
| - When variables are used, they are subject to standard syntax rules regarding text vs. numeric values. This means that text variables MUST be enclosed in single quotes. | - When variables are used, they are subject to standard syntax rules regarding text vs. numeric values. This means that text variables MUST be enclosed in single quotes. | ||
| - | The following | + | The following shows the same SELECT statement as illustrated above but with a variable in the WHERE clause. |
| - | {{ : | + | <code sql> |
| + | SELECT | ||
| + | CardCode, | ||
| + | CardName | ||
| + | FROM ocrd | ||
| + | WHERE CardCode = ' | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important> | ||
| + | When saving a workflow or opening the SQL/HANA tool or the workflow, the reader command type will validate the written query. This executes the query against the connected database. **There is the ability to have Non-query commands written using the Reader command type. This will execute the statement against the database. If a Create, Update, Insert, Truncate or Delete (any SQQL/HANA statement that affects a change to any data) is written, the command will execute and be run against the connected database if the workflow is saved or the tool or workflow is opened** | ||
| + | </ | ||
| ===== Non-Query (SQL Server only) ===== | ===== Non-Query (SQL Server only) ===== | ||
| - | - This command is used for **UPDATE, INSERT, DELETE and STORED PROCEDURES** with or without | + | - This command is used for **UPDATE, INSERT, DELETE, and STORED PROCEDURES** with or without |
| - Variables representing values from previous steps can be used in the statement as needed. Press <F4> for a list of available variables. | - Variables representing values from previous steps can be used in the statement as needed. Press <F4> for a list of available variables. | ||
| - Keep in mind that these statements will affect your data immediately. **Use them with care**. | - Keep in mind that these statements will affect your data immediately. **Use them with care**. | ||
| Line 77: | Line 87: | ||
| <WRAP center round info> | <WRAP center round info> | ||
| - | This option is included for compatibility with older versions of Bizweaver, and is no longer used. The same thing can be accomplished using a “Non-query” operation as illustrated below. The SQL statement will be the same. | + | This option is included for compatibility with older versions of Bizweaver and is no longer used. The same thing can be accomplished using a “Non-query” operation, as illustrated below. The SQL statement will be the same. |
| </ | </ | ||
| - | {{ :bw:sqlimage3.png? | + | {{ :bw2:bizweaversqltool2.png |}} |
| =====Stored Procedure (SQL Server only) ===== | =====Stored Procedure (SQL Server only) ===== | ||
| - | This command can be used to execute a SQL Stored Procedure that does not require parameters. In this case the “exec” statement is not used. All that is required is the name of the procedure. In most cases, it is probably easier to simply always use the Non-Query option to avoid confusion. | + | This command can be used to execute a SQL Stored Procedure that does not require parameters. In this case, the “exec” statement is not used. All that is required is the name of the procedure. In most cases, it is probably easier to simply always use the Non-Query option to avoid confusion. |
| ====Passing Parameters using Stored Procedures (SQL Server only) ==== | ====Passing Parameters using Stored Procedures (SQL Server only) ==== | ||
| - | While there is a “Stored Procedure” command in the SQL Command tool drop down menu, its use is currently limited as it does not support the use of input parameters. To address this, the **Non-Query** command can also be used to execute stored procedures that include parameters for execution. In this case the “exec” statement must be included in the command. The parameters are passed using standard SQL Server syntax. For example, assume a stored procedure that includes two parameters. The SQL statement would be: | + | While there is a “Stored Procedure” command in the SQL Command tool drop-down menu, its use is currently limited as it does not support the use of input parameters. To address this, the **Non-Query** command can also be used to execute stored procedures that include parameters for execution. In this case, the “exec” statement must be included in the command. The parameters are passed using standard SQL Server syntax. For example, assume a stored procedure that includes two parameters. The SQL statement would be: |
| <code sql> exec Stored_Proc_Name parm1, parm2 </ | <code sql> exec Stored_Proc_Name parm1, parm2 </ | ||
| Line 99: | Line 109: | ||
| - Any “calculated” value in a SQL statement must have an alias assigned for it to be available in Bizweaver. This applies to numeric calculations, | - Any “calculated” value in a SQL statement must have an alias assigned for it to be available in Bizweaver. This applies to numeric calculations, | ||
| - | - When using the {RetKey} variable in a SQL Command statement, it should always be enclosed in single quotes. If this is not done the validation process will raise an error. | + | - When using the {RetKey} variable in a SQL Command statement, it should always be enclosed in single quotes. If this is not done, the validation process will raise an error. |
| - | - When variables are used in a SQL statement, the normal rules regarding quotes apply. This means that if the value represented by the variable is a string, the variable in the statement should be enclosed in single quotes as well. For example, the value ItemCode is selected in a Reader step named “GetData”. When this value is used in a subsequent step the associated variable is enclosed in single quotes as shown here: | + | - When variables are used in a SQL statement, the normal rules regarding quotes apply. This means that if the value represented by the variable is a string, the variable in the statement should be enclosed in single quotes as well. For example, the value ItemCode is selected in a Reader step named “GetData”. When this value is used in a subsequent step, the associated variable is enclosed in single quotes as shown here: |
| < | < | ||
| ====== SQL Test Run Option ====== | ====== SQL Test Run Option ====== | ||
| - | Bizweaver version 2.3 introduces the **Test Run** option in the SQLCommand tool. This option allows you to test SQL functions without running through the entire workflow. | + | Bizweaver version 2.3 introduces the **Execute** option in the SQLCommand tool. This option allows you to test SQL functions without running through the entire workflow. |
| - | {{ :bw:sqlcommandtooltestrunstep1.png?500 |}} | + | {{ :bw2:bizweaversqltool3.png |}} |
| - | To invoke this option click on the "Test Run" link in the lower-right corner of the tool window. | + | To invoke this option, click on the "Execute" link in the lower-right corner of the tool window. |
| - | {{ :bw:testrunstep2.png? | + | {{ :bw2:bizweaversqltool4.png |}} |
| Test view | Test view | ||
| - | {{ :bw:sqlcommandtooltestrunstep3.png? | + | {{ :bw2:bizweaversqltool5.png |}} |
| - | The [Result] tab displays the results of the SQL statement. | + | The [Result] tab displays the results of the SQL statement. |
| - | + | ||
| - | {{ : | + | |
| - | + | ||
| - | In this example we can enter a valid value where the variable | + | |
| <code sql> | <code sql> | ||
| Line 128: | Line 134: | ||
| <WRAP center round important 60%> | <WRAP center round important 60%> | ||
| - | Changes in the [Result] tab **DO NOT** automatically carry back to the [SQL] tab. If you make changes in the [Result] tab that need to be in the " | + | Changes in the [Result] tab **DO NOT** automatically carry back to the [SQL] tab. If you make changes in the [Result] tab that needs to be in the " |
| - | + | ||
| - | Click the green <color # | + | |
| </ | </ | ||
| + | |||
| + | ====== SQL System Variables ====== | ||
| + | |||
| + | ^ Name ^ Description | ||
| + | | CommandType | ||
| + | | DataSourceFields |The fields pulled from the data source will only show up when executing the query in the SQL tool and not during a test run| | ||
| + | | DataSourceResultsTable | ||
| + | | QueryString | ||
| + | | SQLCommand | ||
| + | | SQLResultsCount | ||
| + | |StepMessage | ||
| + | | StepStatus | ||
| + | |||
| ======SQL Tips====== | ======SQL Tips====== | ||
| - | * [[bw2:sql tools|Strip HTML Tags From Input String]] | + | |