Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 03 Jun 2011 @ 17:57:35 GMT


     
  <Prev Next>   <<First <Prev
Next>
Last>>
 


Subj:   Re: Mload-vartext file
 
From:   Singh, Sudhansu

You can do this using a shell script. Try this shell script.

     #! /usr/bin/ksh

     n1=$( wc -l < datafile.txt )

     n2=`expr $n1 - 1`

     mload << EOI

     .LOGTABLE MLLOG;
     .LOGON ;

     DROP TABLE a;
     DROP TABLE b;
     DROP TABLE c;

     CREATE TABLE a,FALLBACK (c1 INTEGER,c2 char(10),c3 INTEGER);
     CREATE TABLE b,FALLBACK (c1 INTEGER,c2 char(10),c3 INTEGER);
     CREATE TABLE c,FALLBACK (c1 INTEGER,c2 char(10),c3 INTEGER);

     .BEGIN IMPORT MLOAD TABLES a, b, c;

     .LAYOUT LAY1A;
     .FIELD aa  *  VARCHAR(2);
     .FIELD bb  *  VARCHAR(6);
     .FIELD cc  *  VARCHAR(4);

     .DML LABEL LABELA;
     INSERT INTO a VALUES (:aa,:bb,:cc);

     .DML LABEL LABELB;
     INSERT INTO b VALUES (:aa,:bb,:cc);

     .DML LABEL LABELC;
     INSERT INTO c VALUES (:aa,:bb,:cc);

     .IMPORT INFILE datafile.txt FORMAT vartext '|' for 1 LAYOUT LAY1A APPLY LABELA;
     .IMPORT INFILE datafile.txt FORMAT vartext '|' from 2 thru ${n2} LAYOUT LAY1A APPLY LABELB;
     .IMPORT INFILE datafile.txt FORMAT vartext '|' from ${n1} LAYOUT LAY1A APPLY LABELC;

     .END mLOAD;

     .LOGOFF;
     EOI

regards,

Sudhansu



     
  <Prev Next>   <<First <Prev
Next>
Last>>
 
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023