官术网_书友最值得收藏!

I hate hardcoding – parameters and variables

When you work on any technology, it is always advised that your code be dynamic. This means that you should use the hardcoded values as less as possible in your code. It is always recommended that you use the parameters or the variable in your code so that you can easily pass these values and don't need to change the code frequently. We will discuss this concept in more detail in the Parameters file section in Chapter 5, Using the Workflow Manager Screen – Advanced.

In this section, we will discuss how to use parameters and variables on the PowerCenter Designer screen.

The value of a variable can change between the session run. The value of a parameter will remain constant across the session runs. The difference is very minute, so you should define parameters and variables properly, as per your requirements.

Consider a filter transformation where you have defined the filter condition as LOCATION='USA'. As you have used hardcoded values in the filter conditions, it is always recommended that you pass the value using a parameter or variable.

Follow these steps to use variables or parameters:

  1. In the designer, navigate to Tools | Mapping Designer | Mapping | Parameters and Variables, as shown in the following screenshot:
    I hate hardcoding – parameters and variables
  2. A new window will pop up allowing you to provide parameters and variables, as shown in the following screenshot. Add a new parameter or variable depending on your requirement. For our reference, we are creating a $$LOCATION. $$ parameter that is used as a mapping level variable or parameter. From the dropdown, you can choose whether you wish to make it a parameter or a variable. Then, click on OK.
    I hate hardcoding – parameters and variables
  3. Once you define the parameter or variable at the mapping level, you can use them in the transformations. Take a look at the following screenshot:
    I hate hardcoding – parameters and variables

With this, we have defined a parameter or a variable at the mapping level and used it in the transformations in order to avoid hardcoding.

主站蜘蛛池模板: 荔浦县| 含山县| 永川市| 潮州市| 馆陶县| 湘潭县| 西吉县| 崇信县| 榆中县| 丰宁| 北安市| 上栗县| 瑞金市| 武胜县| 玉龙| 四会市| 贵溪市| 同江市| 兴宁市| 阿克苏市| 达日县| 龙川县| 淅川县| 天柱县| 龙里县| 农安县| 麻江县| 石河子市| 阳原县| 新竹市| 唐海县| 安康市| 忻州市| 洛浦县| 雷山县| 宜城市| 嫩江县| 台中县| 运城市| 德钦县| 葫芦岛市|