Example - Passing Request Information

Here is an example of a DB2® open session command block which, when executed, generates a set of parameters to be passed to a user-defined procedure.

The example combines macro functions to ensure that the values are generated as valid string literals and string concatenations with some literals. The modelPath variable is an example of how to access properties of a request that was processed when the block was executed.

<commandBlock>
	<commands>
		<sqlCommand>
			<sql> CALL myproc(#sq($current_timestamp) + ',' + 
            sq($machine) + ',' + 
            sq(#$modelPath}#) + 'Constant1''''#)
			</sql>
		</sqlCommand>
	</commands>
</commandBlock>

After the macro is expanded, the database administrator obtains the following information about the query:

CALL myproc('2009-05-27 08:13:33.425-05:00','USERCOMPUTERNAME','/content/package[@name=''EAPPS'']/model[@name=''model'']', 'Constant1', '')