Updated on 2024-07-19 GMT+08:00

Teradata Perl Migration

Overview

This section describes how to migrate Teradata Perl files.

Run the runDSC.sh or runDSC.bat command and set --application-lang to perl to migrate Teradata BTEQ or SQL_LANG scripts in Perl files to Perl-compatible GaussDB(DWS). After migrating Perl files, you can verify the migration by comparing the output file with its input file using a comparison tool.

The Perl file migration process is as follows:

  1. Complete the steps in section Prerequisites.
  2. Create an input folder and copy the Perl files to be migrated to the folder. For example, create a /migrationfiles/perlfiles folder.
  3. Execute DSC to migrate Perl scripts and set db-bteq-tag-name to BTEQ or db-tdsql-tag-name to SQL_LANG.
    1. The DSC extracts the BTEQ or SQL_LANG scripts from the Perl files.
      1. BTEQ is the tag name, which contains a set of BTEQ scripts. This tag name is configurable using the db-bteq-tag-name configuration parameter in perl-migration.properties file.
      2. SQL_LANG is another tag name, which contains Teradata SQL statements. This is also configurable using the db-tdsql-tag-name configuration parameter.
    2. DSC invokes the Teradata SQL to migrate the extracted SQL scripts. For details about Teradata SQL migration, see Teradata SQL Migration.
    3. Perl files are embedded in the migrated scripts.
  4. DSC creates the migrated files in the specified output folder. If no output folder is specified, DSC creates an output folder named converted in the input folder, for example, /migrationfiles/perlfiles/converted.
    • Perl variables containing SQL statements can also be migrated to SQL by setting the migrate-variables parameter.
    • For perl v 5.10.0 and later are compatible.

Teradata Perl Migration

To migrate Perl files, execute DSC with --source-db Teradata and --application-lang Perl parameter values. DSC supports the migration of BTEQ and SQL_LANG scripts. You can specify the scripts to be migrated by setting db-bteq-tag-name or db-tdsql-tag-name.

Run the following commands to set the source database, input and output folder paths, log paths, and application language.

Linux:

./runDSC.sh 
--source-db|-S Teradata
[--application-lang|-A Perl]
[--input-folder|-I <input-script-path>]
[--output-folder|-O <output-script-path>] 
[--conversion-type|-M <Bulk or BLogic>]
[--log-folder|-L <log-path>]

Windows:

runDSC.bat
--source-db|-S Teradata
[--application-lang|-A Perl]
[--input-folder|-I <input-script-path>]
[--output-folder|-O <output-script-path>] 
[--conversion-type|-M <Bulk or BLogic>]
[--log-folder|-L <log-path>]
For example:
./runDSC.sh --input-folder /opt/DSC/DSC/input/teradata_perl/ --output-folder /opt/DSC/DSC/output/ --source-db teradata --conversion-type Bulk --application-lang PERL

During the execution of DSC, the migration summary, including the progress and completion status, is displayed on the console.

********************** Schema Conversion Started *************************  
DSC process start time : Mon Jan 20 17:24:49 IST 2020  
Statement count progress 100% completed [FILE(1/1)]    
Schema Conversion Progress 100% completed  
**************************************************************************   
Total number of files in input folder : 1  
**************************************************************************  
Log file path :....../DSC/DSC/log/dsc.log  
DSC process end time : Mon Jan 20 17:24:49 IST 2020  
DSC total process time : 0 seconds 
 ********************* Schema Conversion Completed ************************

For details about the parameters for Teradata Perl migration, see Teradata Perl Configuration.

For details about CLI parameters, see Database Schema Conversion.

  • DSC formats the input files and saves them in the output folder. You can compare the formatted input files with the output files.
  • Ensure that there are no spaces in the input path. If there is a space, DSC throws an error. For details, see Troubleshooting.
  • For details about logs, see Log Reference.
  • If the output folder contains subfolders or files, DSC deletes the subfolders and files or overwrites them based on parameter settings in the application.properties configuration file in the config folder before the migration. Deleted or overwritten subfolders and files cannot be restored by DSC.
  • Process start time indicates the migration start time and Process end time indicates the migration end time. Process total time indicates the total migration duration, in milliseconds. In addition, the total number of migrated files, total number of processors, number of used processors, log file path, and error log file path are also displayed on the console.
  • Set --add-timing-on to true in the perl-migration.properties file to add a custom script to calculate statement execution time.

    Example:

    Input
    1
    2
    3
    4
    $V_SQL2 = "SELECT T1.userTypeInd FROM T07_EBM_CAMP T1  WHERE T1.Camp_List_Id = '$abc'";
    $STH = $dbh->prepare($V_SQL2);
    $sth->execute();
    @rows = $sth->fetchrow();
    
    Output
    $V_SQL2 = "SELECT T1.userTypeInd FROM T07_EBM_CAMP T1  WHERE T1.Camp_List_Id = '$abc'";
    $STH = $dbh->prepare($V_SQL2);
    use Time::HiRes qw/gettimeofday/;
    my $start = [Time::HiRes::gettimeofday()];
    $sth->execute();
    my $elapsed = Time::HiRes::tv_interval($start);
    $elapsed = $elapsed * 1000;
    printf("Time: %.3f ms\n", $elapsed);
    @rows = $sth->fetchrow();
  • GROUP and OTHERS must not have write permission for the files or folders specified by--input-folder. That is, the privilege for the folder specified by --input-folder must not be higher than 755. For security purposes, DSC will not be executed if the input files or folders have the write permission.
  • If migration tasks are executed concurrently, the input folder must be unique for each task.

Best Practices

To optimize the migration, you are advised to follow the standard practices:

  • BTEQ scripts must be in the following format:
    print BTEQ <<ENDOFINPUT;
    TRUNCATE TABLE employee;
    ENDOFINPUT
    close(BTEQ);
  • SQL_LANG scripts must be in the following format:
    1
    2
    3
    my $sSQL=<<SQL_LANG;
    TRUNCATE TABLE employee;
    SQL_LANG
    
  • Comment must not contain the following information:
    • print BTEQ <<ENDOFINPUT
    • ENDOFINPUT
    • close(BTEQ)
    • my $sSQL=<<SQL_LANG
    • SQL_LANG