Search code examples
teradataddl

Teradata Parallel Transporter DDL Operator - missing { EXTENDED_LITERAL_ CHAR_STRING_LITERAL_ } in Rule: Character String Literal ERROR


What I want to do is check in my database if my table exists, if yes drop it. Here is my .tpt :

DEFINE JOB DELETE_ET_TABLES
DESCRIPTION 'Delete ET tables'
(
        DEFINE OPERATOR DDL_OPERATOR
          DESCRIPTION 'Teradata Parallel Transporter DDL Operator'
          TYPE DDL
          ATTRIBUTES
          (
                varchar TdpId = @TERADATA_TDP,
                varchar UserName = @User,
                varchar UserPassword = @Pwd
          );

        APPLY  
                'SELECT (CASE WHEN TableName = ''Test_Del'' 
                              THEN (''DROP TABLE @Table;'')
                              ELSE NULL
                         END)
                 FROM dbc.TablesV WHERE databasename = @Db;'  TO OPERATOR(DDL_OPERATOR);

And this is the error message I am getting :

Running "tbuild" command: tbuild -f /$HOME/loaders/test_deleteETTables.tpt -u TERADATA_TDP=$TDP, TERADATA_DATABASE=$DB -L /$LOG/
Teradata Parallel Transporter Version 16.20.00.09 64-Bit
TPT_INFRA: Syntax error at or near line 18 of Job Script File '/$HOME/loaders/test_deleteETTables.tpt':
TPT_INFRA: At "(" missing { EXTENDED_LITERAL_ CHAR_STRING_LITERAL_ } in Rule: Character String Literal
Compilation failed due to errors. Execution Plan was not generated.

Do you have any idea ? I have tried multiple things, such as :

SELECT 1 FROM dbc.TablesV WHERE databasename = @Db AND TABLENAME ='TEST_DEL';
CASE WHEN ACTIVITYCOUNT = 1
    THEN (DROP TABLE @Table)
    ELSE ( QUIT )
END;

All my variables have been declared. I feel that it is a problem with using single quotes inside que statement but I am not sure and I don't know how to resolve it. Thank you very much for your time.


Solution

  • The solution that Fred recommended me to try in the comments worked just fine :

    I think this is due to use of NULL but SELECT is not valid for DDL operator. The recommended way to do this is simply pass a DROP to the operator and tell it to ignore "not found" (and consider that success), i.e. ErrorList='3807'

    DESCRIPTION 'Delete ET tables'
    (
            DEFINE OPERATOR DDL_OPERATOR
              DESCRIPTION 'Teradata Parallel Transporter DDL Operator'
              TYPE DDL
              ATTRIBUTES
              (
                    varchar TdpId = @TERADATA_TDP,
                    varchar UserName = @USERDB,
                    varchar UserPassword = @PWD,
                    VARCHAR ErrorList = '3807'
              );
    
            APPLY
            ('DROP TABLE @TABLENAME')
            TO OPERATOR(DDL_OPERATOR);
    );```