如何获得插入的行数?

时间:2019-04-24 09:22:03

标签: database csv unix teradata

我正在使用CSV文件在Unix中使用.tpt文件加载 Teradata 数据库。有什么方法可以获取插入到表中的行数?与任何助手一样,典型消息为X Rows Inserted。我要得到的是X。谢谢。这是我的.tpt文件之一的代码:

DEFINE JOB X_1
DESCRIPTION 'LOADING OF TABLE TABLE_1'
(
    DEFINE SCHEMA X_1
    (
        _FIELD_1            VARCHAR(8)
        ,_FIELD_2   VARCHAR(20)
        ,_FIELD_3       VARCHAR(20)
    );

    DEFINE OPERATOR DDL_OPERATOR
    TYPE DDL_OPERATOR
    ATTRIBUTES
    (
        VARCHAR PrivateLogName      = 'ddl_log'
        ,VARCHAR TdpId              = @jobvar_TDP
        ,VARCHAR UserName           = @jobvar_username
        ,VARCHAR UserPassword       = @jobvar_password
        ,VARCHAR QueryBandSessInfo  = @jobvar_QBSessInfo
        ,VARCHAR ErrorList          = '3807'
    );

    DEFINE OPERATOR FILE_READER
    TYPE DATACONNECTOR PRODUCER
    SCHEMA X_1
    ATTRIBUTES
    (
        VARCHAR PrivateLogName      = 'dataconnector_log'
        ,VARCHAR DirectoryPath      = @jobvar_datafiles_path
        ,VARCHAR FileName           = @jobvar_file_load
        ,VARCHAR Format             = 'Delimeted'
        ,VARCHAR TextDelimeter      = '|'
        ,INTEGER SkipRows           = 1
        ,VARCHAR OpenMode           = 'Read'
    );

    DEFINE OPERATOR LOAD_OPERATOR
    Type LOAD
    SCHEMA *
    ATTRIBUTES
    (
        VARCHAR PrivateLogName      = 'load_op_log'
        ,VARCHAR TdpId              = @jobvar_TDP
        ,VARCHAR UserName           = @jobvar_username
        ,VARCHAR UserPassword       = @jobvar_password
        ,INTEGER MaxSessions        = @jobvar_maxsessions
        ,INTEGER ErrorLimit         = 1
        ,VARCHAR Targettable        = @jobvar_tgt_dbname || '.TABLE_1'
        ,VARCHAR LogTable           = @jobvar_tgt_dbname || '.LG_TABLE_1'
        ,VARCHAR ErrorTable1        = @jobvar_tgt_dbname || '.ET_TABLE_1'
        ,VARCHAR ErrorTable2        = @jobvar_tgt_dbname || '.UV_TABLE_1'
    );

    STEP Setup_Tables
    (
        APPLY
            ('DROP TABLE    ' || @jobvar_tgt_dbname || '.ET_TABLE_1;'),
            ('DROP TABLE    ' || @jobvar_tgt_dbname || '.LG_TABLE_1;'),
            ('DROP TABLE    ' || @jobvar_tgt_dbname || '.UV_TABLE_1;'),
            ('DROP TABLE    ' || @jobvar_tgt_dbname || '.TABLE_1;'),
            ('CREATE MULTISET TABLE ' || @jobvar_tgt_dbname || '.TABLE_1
            (
                FIELD_1 VARCHAR(8) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL,
                FIELD_2 VARCHAR(20) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL,
                FIELD_3 VARCHAR(20) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL
            )PRIMARY INDEX(FIELD_1, FIELD_2, FIELD_3);'
            )
        TO OPERATOR (DDL_OPERATOR);
    );
    STEP Load_TABLE_1_Table
    (
        APPLY
            ('INSERT INTO ' || @jobvar_tgt_dbname || '.TABLE_1
            (
                FIELD_1
                ,FIELD_2
                ,FIELD_3
            )
            VALUES
            (
                _FIELD_1
                ,_FIELD_2
                ,_FIELD_3
            )
            ;')

    )
)

1 个答案:

答案 0 :(得分:1)

您可以使用-f TWB_EVENTS的{​​{1}}(对于tlogview的插入计数grep)从作业的TPT日志文件中提取信息。 查看 TPT用户指南中的操作元数据一章。

根据您的Teradata版本和QueryLog设置,您也可能会在LoadRowsInserted视图中找到作业详细信息。