# Conditional Plug-in Execution

You can configure any plug-in to execute conditionally. In other words, a plug-in can decide whether or not to process a session based on a set criteria.

The criteria is configured in the MT-SQL language (see the help on the Arithmetic Plug-in for details), and is embedded in a <condition> block in the plug-in's configuration file (placed just before the <configdata> block). The condition block's MT-SQL procedure sets an _ExecutePlugin boolean reserved property. If the property is TRUE, then the plug-in executes. If FALSE, it does not.

Unlike a normal MT-SQL plug-in procedure, for practical purposes a conditional procedure is read-only. It sets only one property into session, the _ExecutePlugin property.

This feature is fully compatible with session sets.

## Configuration Example

This example executes a rate lookup only if the property Units is greater than 100:

<xmlconfig>

<mtsysconfigdata>

<effective_date ptype="DATETIME">2001-04-06T21:46:29Z</effective_date>

<timeout ptype="INTEGER">365</timeout>

<configfiletype>CONFIG_DATA</configfiletype>

</mtsysconfigdata>

<mtconfigdata>

<version ptype="INTEGER">1</version>

<processor>

<name>rcratelookup</name>

<progid>MetraPipeline.PCRate.1</progid>

<description></description>

<condition>

<![CDATA[

CREATE PROCEDURE condition @_ExecutePlugin BOOLEAN @Units DOUBLE

AS

IF (CAST(@Units AS DECIMAL) > 100.0)

SET @_ExecutePlugin = TRUE

ELSE

SET @_ExecutePlugin = FALSE

]]>

</condition>

<configdata>

<RateLookup>

<ParamTable>metratech.com/flatrecurringcharge</ParamTable>

</RateLookup>

<properties>

<_timestamp>RateDate</_timestamp>

</properties>

</configdata>

</processor>

</mtconfigdata>

</xmlconfig>