Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

Using templates for operators provided in TPT - response (10) by sahmed448

$
0
0

Hello,
Can someone please help me with a sample TPT script using update operator to load multiple tables based on the condition: if the value of the first column of the row in the input data file is 'abc' then load table 1
if the value is 'xyz' then load table 2.
Input file looks something like this:
abc 100 mike   IT  programer
abc 101 james  sales    Salesmen
abc 200 frank  DBA      administration
xyz 10  Marketing
xyz 11  administration
abc 600 John   Marketing executive
abc 900 Sam   Hardware  workshop
I checked the manual but i coudnt find any direct sample script close to what i am trying to achieve.
 
Here is the code which i have written and doesnt work:
Erro: UPDATE_OPERATOR: TPT10508: RDBMS error 3857: Cannot use value (or macro parameter) to match "IN_Cd".
 
DEFINE JOB FILE_LOAD
DESCRIPTION 'Load 2 TD tables from a file'
(
DEFINE SCHEMA Load_Test_Schema
(
     IN_Table_Name  VARCHAR(30)
    ,IN_Cd     VARCHAR(255)
    ,IN_Field_1     VARCHAR(1000)
    ,IN_Field_2     VARCHAR(1000)
    ,IN_Field_3     VARCHAR(1000)
    ,IN_Field_4     VARCHAR(1000)
    ,IN_Field_5     VARCHAR(1000)
);
DEFINE OPERATOR DDL_OPERATOR
TYPE DDL
ATTRIBUTES
(
VARCHAR PrivateLogName = 'ddl_log1',
VARCHAR TdpId = @jobvar_tdpid,
VARCHAR UserName = @jobvar_username,
VARCHAR UserPassword = @jobvar_password,
VARCHAR ErrorList = '3807'
);
DEFINE OPERATOR FILE_READER
TYPE DATACONNECTOR PRODUCER
SCHEMA Load_Test_Schema
ATTRIBUTES
(
VARCHAR PrivateLogName = 'dataconnector_log1',
VARCHAR DirectoryPath = '%DDDD%',
VARCHAR FileName = 'testfile.dat',
VARCHAR Format = 'Delimited',
VARCHAR OpenMode = 'Read',
VARCHAR TextDelimiter ='|'
);
DEFINE OPERATOR UPDATE_OPERATOR
TYPE UPDATE
SCHEMA *
ATTRIBUTES
(
VARCHAR PrivateLogName = 'update_log',
VARCHAR TdpId = @jobvar_tdpid,
VARCHAR UserName = @jobvar_username,
VARCHAR UserPassword = @jobvar_password,
VARCHAR LogTable = 'ERRORSDB.LG_Load2',
VARCHAR ARRAY TargetTable = ['devDB.Stagingtble1','devDB.Stagingtble2'],
VARCHAR ARRAY ErrorTable1 = ['ERRDB.ET_Stagingtble1','ERRDB.ET_Stagingtble2'],
VARCHAR ARRAY ErrorTable2 = ['ERRDB.UV_Stagingtble1','ERRDB.UV_Stagingtble2']
);

APPLY CASE WHEN  (IN_Table_Name = 'abc')
THEN
'INSERT INTO devDB.Stagingtble1
        (col1, col2, col3)
  VALUES(:IN_Cd
 ,:IN_Field_1
 ,:IN_Field_2)
;'
WHEN  (IN_Table_Name = 'xyz')
THEN
'INSERT INTO devDB.Stagingtble2
            (col1 
 ,col2 
         )
VALUES ( :IN_Field_4
 ,:IN_Field_5)
;'
END
TO OPERATOR (UPDATE_OPERATOR[2])
SELECT * FROM OPERATOR (FILE_READER[2]);
);
 
Thanks
sahmed


Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>