Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 23 Aug 1999 @ 18:56:53 GMT


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


Subj:   Re: About Oracle and Teradata
 
From:   Bob Maccione

OK, not to be left out, for smaller tables we use the following perl script. Note that we use it mostly for creating temp tables from Informix 'unload to 'foo' select * from 'table' ' commands. We haven't tested it on very large tables and don't really care about the speed (although seat of the pants it seems pretty fast). It assumes that you have the teraperl extensions loaded and the example assumes a 2 column table.

usage is: teraload <datafile

It would be trivial to have the perl script connect to the oracle database and get the records itself. However that's not what we wanted to do.


good luck,

bobm


     ----
     #!/usr/bin/perl -w
     # will read from stdin and insert each record into a *new* database

     use Sqlformat;    # includes the teradata interface libary

     my $sess = "";           # session handle
     my @flds ;               # where the field data is going
     my $table = "Eds_temp";  # the name of the table

     $sess = PCli::init("dbc", "database", "user", "");   # connect to the
     local database


     # create the table or die
     PCli::do( $sess, "CREATE table $table ( fld1 integer, fld2 integer ) " )
        || die "Create table error '$PCli::errstr'";


     # parse the input file reading lines and inserting into the database
     while(  ) {
       # remove the |'s in the input string
       @flds = split( /\|/, $_ );

       # there are 2 fields in the array, add them to the table
       PCli::do( $sess, "Insert into $table values ( '$flds[0]', '$flds[1]'
     );" );
     }


     # close the connection
     PCli::disconnect($sess) || warn "$PCli::errstr" if $PCli::errno;


     
  <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