Develop your understanding of parameter bindings. Create a module that defines a parameter that can be bound to an expression or to another parameter in the parent scope.
The module FilterByPrice filters all incoming trades based on price, and outputs only the trades that have a price greater than the value in the minimumPrice parameter.
minimumPrice can be set when FilterByPrice is loaded, or it can be bound to another parameter within the project so that the value of minimumPrice is set when the project is loaded on the server.
CREATE MODULE FilterByPrice IN TradeData OUT FilteredTradeData BEGIN IMPORT 'schemas.ccl'; DECLARE parameter money(2) minimumPrice := 10.00d2; END; CREATE INPUT STREAM TradeData SCHEMA TradesSchema; CREATE OUTPUT STREAM FilteredTradeData SCHEMA TradesSchema AS SELECT * FROM TradeData WHERE TradeData.Price > minimumPrice; END;
LOAD MODULE FilterByPrice AS FilterOver20 IN TradeData = NYSEData OUT FilteredTradeData = NYSEPriceOver20Data PARAMETERS minimumPrice = 20.00d2;In this type of parameter binding, the module outputs stocks only with a price greater than 20.00.
DECLARE parameter money(2) minProjectPrice := 15.00d2; END; LOAD MODULE FilterByPrice AS FilterOverMinProjPrice IN TradeData = NYSEData OUT FilteredTradeData = NYSEPriceOverMinProjPrice PARAMETERS minimumPrice = minProjectPrice;If no value is specified for the project's parameter (minProjectPrice) at runtime, then the module filters based on the project parameter's default value of 15.00. However, if minProjectPrice is given a value at runtime, the module filters based on that value.
LOAD MODULE FilterByPrice AS FilterOver10 IN TradeData = NYSEData OUT FilteredTradeData = NYSEPriceOver10Data;Since no binding is provided in the LOAD MODULE statement, the module filters on its default value of 10.00.