DECLARE PARAM

Overview

The DECLARE PARAM command defines an input variable that can be used throughout the script. Although the parameter values can be overriden by a calling script, they are read-only once the script starts executing. You can optionally specify default values for parameters; while optional, this is a recommended practice in case no values are provided when running the pipeline.

Both default values and overriden values support the use of DataZen functions.

To pass values to the /sql/preview endpoint, you must provide a JSON Array of objects in an HTML comment section (see example below).

Syntax

Declares a parameter that can be overriden when starting a SQL CDC script by including a JSON-formatted parameter block.

PARAM

The name of the parameter being defined

VALUE

The default value to use for this parameter; may be overriden by a parameter block injected at runtime in the SQL CDC script

Example 1

-- Declare a parameter to be used in the SQL CDC script and set a default value
-- The parameter can be overriden, but it is read-only once the script starts
DECLARE @url = 'econi.xml';

-- Parameters can be used throughout the script using the @param notation
SELECT * FROM HTTP [Rss Feed] (GET /{{@param.url}}) APPLY TX (//item);



Example 2

/*

Use the parameter value declaration section as shown below to override 
the SQL CDC parameters declared. 

<!--param
	[ { "url": "econi.xml" } ]
-->

*/

-- Declare a parameter to be used in the SQL CDC script and set a default value
-- The parameter can be overriden, but it is read-only once the script starts
DECLARE @url = 'TEST';

-- Parameters can be used throughout the script using the @param notation
SELECT * FROM HTTP [Rss Feed] (GET /{{@param.url}}) APPLY TX (//item);