TPT Load-Template is a file consumer which works similar to Fastload utility. Advantage of Load-Template is that it eliminates the need to define separate TPT script for each of the table.
There are five data formats in which data can be loaded using TPT. Please visit TPT-Load page for detail of each format type.
#tpt_load_template_delimited.tpt
USING CHARACTER SET @var_utf
DEFINE JOB tpt_load_template
(
STEP DELETE_DATA_FROM_TABLE(
APPLY('DELETE FROM ' || @var_tablename ) TO OPERATOR ($DDL() ATTR (TdpId=@var_tdpid, UserName=@var_userid, UserPassword=@var_password));
);
STEP LOAD_DATA_INTO_TABLE (
APPLY $INSERT TO OPERATOR ($LOAD() ATTR (TdpId=@var_tdpid, UserName=@var_userid, UserPassword=@var_password, TargetTable=@var_tablename, MaxSessions=@var_maxsessions, DateForm = @var_dateform))
SELECT * FROM OPERATOR($FILE_READER(DELIMITED @var_tablename) ATTR (DirectoryPath = @var_directorypath,FileName=@var_inputfile, Format=@var_format, TextDelimiter=@var_delimiter_value, OpenMode = 'Read'));
);
);
Click here to download the above Load-Template script for delimited file.
#tpt_load_template.tpt
USING CHARACTER SET @var_utf
DEFINE JOB tpt_load_template
(
STEP DELETE_DATA_FROM_TABLE(
APPLY('DELETE FROM ' || @var_tablename ) TO OPERATOR ($DDL() ATTR (TdpId=@var_tdpid, UserName=@var_userid, UserPassword=@var_password));
);
STEP LOAD_DATA_INTO_TABLE (
APPLY $INSERT TO OPERATOR ($LOAD() ATTR (TdpId=@var_tdpid, UserName=@var_userid, UserPassword=@var_password, TargetTable=@var_tablename, MaxSessions=@var_maxsessions, DateForm = @var_dateform))
SELECT * FROM OPERATOR($FILE_READER(@var_tablename) ATTR (DirectoryPath = @var_directorypath, FileName=@var_inputfile, Format=@var_format, TextDelimiter=@var_delimiter_value, OpenMode = 'Read'));
);
);
Click here to download the above Load-Template script.
tbuild -f tpt_load_template_delimited.tpt \ -u " var_tdpid='TDSERVER', \ var_userid='tutorial_user', \ var_password='tutorial_user', \ var_inputfile='export_template_outfile.txt', \ var_directorypath='/path_to_input_file', \ var_delimiter_value='|*|', \ var_tablename='tutorial_db.employee', var_utf='UTF8', \ var_maxsessions=4, \ var_dateform='ANSIDATE' \ var_format='DELIMITED'"
tbuild -f tpt_load_template.tpt \ -u " var_tdpid='TDSERVER', \ var_userid='tutorial_user', \ var_password='tutorial_user', \ var_inputfile='export_template_outfile_unformatted.txt', \ var_directorypath='/path_to_input_file', \ var_tablename='tutorial_db.employee', var_utf='UTF8', \ var_maxsessions=4, \ var_dateform='ANSIDATE' \ var_format='UNFORMATTED'"
tbuild -f tpt_load_template.tpt \ -u " var_tdpid='TDSERVER', \ var_userid='tutorial_user', \ var_password='tutorial_user', \ var_inputfile='export_template_outfile_formatted.txt', \ var_directorypath='/path_to_input_file', \ var_tablename='tutorial_db.employee', var_utf='UTF8', \ var_maxsessions=4, \ var_dateform='ANSIDATE' \ var_format='FORMATTED'"
tbuild -f tpt_load_template.tpt \ -u " var_tdpid='TDSERVER', \ var_userid='tutorial_user', \ var_password='tutorial_user', \ var_directorypath='/path_to_input_file', \ var_inputfile='export_template_outfile_binary.txt', \ var_tablename='tutorial_db.employee', var_utf='UTF8', \ var_maxsessions=4, \ var_dateform='ANSIDATE' \ var_format='BINARY'"