Sie sind auf Seite 1von 7

PARAMETER FILE Create Parameter File This mapping refreshes the variable table and populates the parameter

file. It allows users to create and maintain values in the variable table and automatically loads the parameter file with this two-stream process. The first path updates the variable table by retrieving the latest parameter and variable values (i.e., maximum) specified for lookup to apply later in the workflow. It also arranges the table in folder, session and parameter order. The second path formats the data from the variable table to create the parameter file.

How it Works The parameters and corresponding values, organized by folder and session, reside in the PARM_TABLE. The values can be changed manually or automatically. All fields provide the option of manual manipulation of the data by inserting or updating rows. To update, simply modify the VALUE field in the PARM_TABLE. Some parameters, such as Version, possess a lookup to search fields in a target table and retrieve the maximum value when the ENABLE_ROW field is set to Y. To ignore the lookup procedure, set the ENABLE_ROW field to N. Once all changes are made to the variable table, issue a commit. To pass the updates to the parameter file, run the s_m_Create_Parameter_File session. There are two parts to the session. The first segment processes each row in the PARM_TABLE sorting by folder, session and parameter then reassigns the parm_id into the same table. If a row requires a search on another table, it checks to see whether the ENABLE_ROW field is set to Y. If yes, the lookup will occur to determine the true maximum value. The lookup is only executed once because the new value will be passed for succeeding requests during the run. If not, it will pass the value that is currently in the field.

The second portion takes the PARM_TABLE again and groups the records by folder and session. On the first group occurrence, the folder, session, parameter and value are passed. For following instances, however, the file only gets the parameter and value. Each row is loaded in the parameter file, parm_file.txt, in the source directory under the Informatica server (root/$PMSourceFileDir/). All sessions containing mapping parameters and variables will refer to the parameter file to retrieve the current values. Table The two sources and target for the first stream is PARM_TABLE. The three keys are FOLDER_NAME, SESSION_NAME and PARAMETER_NAME whereas the PARM_ID is only provided to sort the records. The script to create the table, PARM_TABLE, is as follows: CREATE TABLE PARM_TABLE ( PARM_ID NUMBER, FOLDER_NAME VARCHAR2(20) SESSION_NAME VARCHAR2(50) PARAMETER_NAME VARCHAR2(30) VALUE VARCHAR2(30), ENABLE_ROW CHAR(1) );

NOT NULL, NOT NULL, NOT NULL,

ALTER TABLE PARM_TABLE ADD PRIMARY KEY (FOLDER_NAME, SESSION_NAME, PARAMETER_NAME); Transformations Stream #1: Resetting Variables Lookup (Unconnected): lkp_maxParameter This lookup retrieves the maximum value of the field (i.e., version) in the target table. Ports Tab Inputs: v_Dummy Outputs: VR Lookups: All target table fields Returns: VR Properties Tab (Non-Defaults) Lookup Sql Override: Generate SQL and put max() on field in the select clause Example: SELECT max(Table1.VR) as VR FROM Table1

Lookup table name: Target table where lookup value exists Location Information: Database schema containing table with lookup field Condition Tab VR != v_Dummy

Source/Source Qualifier: PARM_TABLE Keys - FOLDER_NAME, SESSION_NAME, PARAMETER_NAME Ports Tab Number of Sorted Ports: 3 (folder, session and parameter respectively according to the keys) NOTE: Folder, session and parameter names MUST be the first 3 output rows to sort properly Sequence Generator: seq_Parm_ID This sequence generator resets the ids for the variable table. Ports Tab NEXTVAL (Connect to Parm ID) Properties Tab Check Reset Box Leave other parameters as default Expression: exp_Parm_Values This expression obtains the current value from the related tables according to input parameter. Ports Tab Inputs: Pass in the fields from the source Outputs: - Apply PARAMETER_VALUE logic - Apply PARM_ID logic PARAMETER_VALUE logic There is a value lookup procedure for each row that is passed. Depending on the parameter name, the value is checked against the corresponding table to retrieve the maximum number and store as a parameter. Variables One local variable for each parameter with only the parameter name Example: v_Parameter1:= $$Parameter1 Dummy Value A value that will never equal the return number is passed to the Lookup for the purpose of access Enable Row The initial check against the ENABLE_ROW field for all expressions in the transformation to determine whether to perform apply the logic or pass the current value

Example: v_Enable_Row:= If(UPPER(ENABLE_ROW)='Y', 1, 0) One-time Lookup A counter indicates the number of times a parameter occurs allowing the lookup to be executed once on the first occurrence Example: v_Parm1_Count:= If(Parameter_Name =$$Parm1, v_Parm1_Count+1, v_Parm1_Count) Out Value If the parameter is equal to the local variable, apply that specific lookup passing in the dummy value to retrieve the maximum number, else use the value passed in when there is no lookup Example: Out_Value:= DECODE(Parameter_Name, v_Parameter1, v_maxParameter1, v_Parameter2, v_maxParameter2, , v_ParameterN, v_maxParameterN, IN_value)

PARM_ID logic The parameter id is strictly present to supply a surrogate key to the rows in the variable table. In fact, they can potentially change between runs depending on the order of the parameters. When each record propagates through the mapping a sequential number is assigned incrementally resetting to one for each run. Drop the PARM_ID from the source Replace with value from the Sequence Generator transformation In Sequence Generator transformation, seq_Parm_ID, pass the NEXTVAL field and check the Reset checkbox (use default for all other fields) Expression Snapshot: exp_Parm_Values PORT NAME
v_Dummy v_Enable_Row v_Version v_Version_Cnt v_Version_Val IN_VALUE FOLDER_NAME SESSION_NAME PARAMETER_NAME ENABLE_ROW PARM_ID OUT_VALUE

PORT TYPE
Variable Variable Variable Variable Variable Input I/O I/O I/O I/O I/O Output

EXPRESSION
X IIF(UPPER(ENABLE_ROW)='Y', 1, 0) '$$Version' IIF(v_Enable_Row=1 AND PARAMETER_NAME=v_Version, v_Version_Cnt +1, v_Version_Cnt) IIF(v_Enable_Row=1 AND PARAMETER_NAME= v_Version AND v_Version_Cnt=1,:LKP.lkp_Version(v_Dummy), v_Version_Val) <From VALUE field of source qualifier> <From source qualifier> <From source qualifier> <From source qualifier> <From source qualifier> <From NEXTVAL field of seq_Parm_ID> IIF(v_Enable_Row=1, DECODE(PARAMETER_NAME, v_Version, v_Version_Cnt, v_Parameter, v_Parameter_Val, , IN_VALUE), IN_VALUE)

Update Strategy: upd_Parm_Values This update strategy flags the fields from the expression as updates for the variable table. Properties Tab Update Strategy Expression: DD_UPDATE Target: PARM_TABLE Key - FOLDER_NAME, SESSION_NAME, PARAMETER_NAME NOTE: The keys are the folder, session and parameter names and MUST exists to apply the update strategy Stream #2: Load Parameter File Source/Source Qualifier: PARM_TABLE Keys - FOLDER_NAME, SESSION_NAME, PARAMETER_NAME Ports Tab Number of Sorted Ports: 2 (folder and session respectively according to the header order) NOTE: Folder and session MUST be the first 2 output rows to sort properly Expression: exp_Parm_String This expression organizes the fields in the variable table into the parameter field format Port Tab Inputs: Pass in the fields from the source (folder and session must be first and parm id & enable_row is not required) Outputs: Text field (apply PARAMETER_FILE logic) PARAMETER_FILE logic The parameter file can only be read in a specific format. The layout used is the following: [FOLDER_NAME.SESSION_NAME] $$PARAMETER1_NAME=VALUE1 $$PARAMETER2_NAME=VALUE2 The local variable logic is used to accommodate cases for sessions with multiple parameters. Hence, the significance of the folder and session sort in the source qualifier. Header Set header local variable to the concatenation of the folder and session Example: v_Header:= FOLDER_NAME || + || SESSION_NAME NOTE: A + is added to distinguish the folder from the session name

Counter If header equals previous header, set counter local variable to Counter plus 1, else 1 Example: v_Counter:= IF(v_Header=v_PrevHeader, v_Counter+1, 1) Previous Header Set previous header local variable to current header Example: v_PrevHeader:= v_Header NOTE: Order of local variable DOES matter when comparing Header to previous Header Parameter String Set to both Header and Parameter Line format if Counter equals 1, else just the Parameter Line Example: Parm_String:= IF(v_Counter=1, ['||FOLDER_NAME||'.'|| SESSION_NAME']'||chr(10)||PARAMETER_NAME||'='|| VALUE, PARAMETER_NAME||'='||VALUE) NOTE: chr(10) is the ASCII value for a carriage return

Expression Snapshot: exp_Parm_String PORT NAME


IN_VALUE FOLDER_NAME SESSION_NAME PARAMETER_NAME VALUE v_Header v_Counter v_PrevHeader Parm_String

PORT TYPE
Input Input Input Input Input Variable Variable Variable Output

EXPRESSION
<From VALUE field of source qualifier> <From source qualifier> <From source qualifier> <From source qualifier> <From source qualifier> LTRIM(RTRIM(FOLDER_NAME)) || '+' || LTRIM(RTRIM(SESSION_NAME)) IIF(v_Header = v_PrevHeader, v_Counter + 1, 1) V_Header IIF(v_Counter = 1, chr(10)||'['||RTRIM(FOLDER_NAME,' ')||'.'|| RTRIM(SESSION_NAME,' ')||']'||chr(10)|| RTRIM(PARAMETER_NAME,' ')||'='||RTRIM(VALUE), RTRIM(PARAMETER_NAME,' ')||'='||RTRIM(VALUE))

Target: Parameter File Text field with a large length Target Load Plan The mapping load sequence can be set when there are multiple source qualifiers. Being that there are two streams in this process, the run in order is imperative. The Target Load Plan must be established to execute the table load first, followed by the creation of the parameter file. From the menu bar in Designer, select Mappings/Target Load Plan and arrange the mapping order.

s_m_Create_Parameter_File Session Parameters General Tab Check box for Fail parent if this task fails Properties Tab Treat source rows as = Data Driven Targets (Properties) Tab Target load type = Normal Update else Insert checkbox is checked Output file directory = $PMSourceFileDir\ Output filename = parm_file.txt

Add a New Parameter Values that can potentially change in production need to be assigned to a mapping parameter. If a new parameter needs to be added, the following steps need to be applied: 1. Create parameter in mapping The parameter is created in Designer by going to the Mappings/Parameters and Variables on the menu bar. Click the add a new variable icon and enter the name, type, datatype, precision and scale 2. Assign parameter in the mapping The parameter can be included in the mapping within a query or expression. Go to the Variables tab in a Source Qualifier query or in the expression of a transformation and select the parameter. Note that if that string datatypes may require quotes. 3. Create entry in the PARM_TABLE Go to the PARM_TABLE and insert a new line. Include the folder, session and parameter name. This value can be a constant or derived. If derived, set the enable row field to Y, otherwise the value becomes a constant and the mapping will use the value entered. 4. Add parameter file to the session Go into the reusable session and under Properties/Parameter Filename enter $PMSourceFileDir\parm_file.txt to look up the parameter value create in the table. 5. Execute parameter session Start the session in Workflow Manager or Workflow Monitor to refresh the parameter file.

Das könnte Ihnen auch gefallen