Howdy:

This may be a DB2 question; if so, let me know and I'll
send the question there -

I have a script that connects to the mainframe and generates
a flat file with data that I want.  Works fine for what I'm
doing.

But now I want to create the outfile in an IXF format, somehow.
I'm looking at groups.google.com and there are a few example,
but, none of them seem to work.  

Has anyone out there used perl to connect to their mainframe
to export their data in another format? (DEL, IXF, ASC, etc ...)
I'm looking for an example of how the syntax is setup.

Thanks!

-X


[script]

#!perl.exe

# created 05 Nov 2002 - X
# script to connect the NT machine to DB2/ OS/390
# mainframe via db2 module (have to run on NT box for now)

# may test this with DBI:DBD:DB2

# this works for bringing back regular text
# gonna work on the IXF thing next - 6 Nov 02 -X

use strict;
use DBI;
use DBD::DB2::Constants;
use DBD::DB2;

my $username="joeuser";
my $password="joepasswd";
my $outfile="newtest.ixf";
my $ixffile="test.ixf";

my $dbh=DBI->connect("dbi:DB2:localdb", $username, $password)
        or die "Can not connect: $!";
if (!defined($dbh)) {exit;}
;

# testing the ixf part - 06 nov 02 - 11am -X

my $sql= system (qq{ db2 export to $ixffile of ixf
SELECT
name, tbname
from sysibm.syscolumns
where tbname = t_table });
warn "db2 export of $ixffile failed: $?" unless $sql ==0;

;

# test the sql and prepare to use
#

my $sth = $dbh->prepare($sql) or die "Error = ", DBI::errstr;

unless ($sth->execute) {
        print"\n\tExecute failed for stmt:\n\t$sql\nError = ", DBI::errstr;
        $sth->finish;
        $dbh->disconnect;
        die "\n\t\tClean up finished\n";
}

# generate a text file for mailing
# will have to expound upon
#

$outfile=$sql;

#open OUTFILE, ">>$outfile";
#print OUTFILE "This is a test ...\n\n";
#while (my ($name, $tablename)=$sth->fetchrow) {
#print OUTFILE "$name\t$tablename\n\n";
#}
#
#close OUTFILE;

$dbh->disconnect;

[/script]

Reply via email to