What error are you seeing?

On 1/10/07, Brimacomb, Brent <[EMAIL PROTECTED]> wrote:
Well I'm new to both Perl and DBD::DB2, so please bare with me.

I've installed the latest Active state Perl, the latest DBI and DBD::DB2
from CPAN.

I'm trying to develop a program that runs on a Windows server that does
a SELECT from a DB2 that's on an Os/390 box running several DB2's.
What I'm looking for is a good example of a program that does that.
Here's what I have, but I can't make the connection work......

 use warnings;
 use strict;
 use diagnostics;

 use DBI;
 use DBD::DB2;
 use DBD::DB2::CONSTANTS;

 print "Operating System = $^O\n";
 print "Perl Binary      = $^X\n";
 print "Perl Version     = $]\n";
 print "DBI Version      = $DBI::VERSION\n";
 print "DBD::DB2 Version = $DBD::DB2::VERSION\n\n";

 my @DB2DataSources = DBI->data_sources("DB2");

 print "Available DB2 DSNs:\n\n";
 foreach my $dsn ( @DB2DataSources )
 {
  print " $dsn \n";
 }

 my $hostname = "dsn2.prdpl.abc123.com";  # This is the hostname of the
server you are wanting to connect to.
 my $port     = "5002";                       # dsn port number.
 my $protocol = "TCPIP";                      # communication protocol
 my $database = "DSN2";                   # This is the database name
that you are connecting to on the above host.
 my $user     = "G156505";                    # User that is connecting
to the database
 my $password = "xxxxxx12";                   # Password the User is
connecting to the database

#  my $dsnx = "dbi:DB2:database=$database; HOSTNAME=$hostname;
PORT=$port; PROTOCOL=$protocol; UID=$user; PWD=$password;";
#  my $dsnx = "dbi:DB2:database=USNETAALDSN2";
 my $dsnx = "dbi:DB2:database=$database; HOSTNAME=$hostname; PORT=$port;
PROTOCOL=$protocol; UID=$user; PWD=$password;";


 my $dbh = DBI->connect($dsnx,
                      $user,
                      $password) || die "Connection failed with error:
$DBI::errstr";

my $sql = qq( SELECT CUS_NBR, CUS_LST_NM FROM TEST.XXXR0471_CUSTAB WHERE
CUS_NBR = 535077);
print $sql;
my $sth = $dbh->prepare( $sql );
$sth->execute();  # Execute the select statement
my ( $cusno, $lastname );
$sth->bind_columns( undef, \$cusno, \$lastname );

while( $sth->fetch() )  {
 print "$empno, $lastname\n";
 }

 $sth->finish();   # Tell the database handle you are finished with it.
 $sth->disconnect();  # Disconnect from the database.


Brent Brimacomb  CISSP, CISM
EDS - Information Security
MS 354
4000 North Mingo Rd.
Tulsa, OK  74116
* phone: +01-918-939-6534
* mailto:[EMAIL PROTECTED]






--
--------------------------------------------------------------------------------------------------------------
The darkest places in hell are reserved for those who maintain their
neutrality in times of moral crisis.
   Dante Alighieri (1265 - 1321)

They who would give up an essential liberty for temporary security,
deserve neither liberty or security.
Benjamin Franklin

Our lives begin to end the day we become silent about things that matter.
Martin Luther King

The right of the people to be secure in their persons, houses, papers,
and effects, against unreasonable searches and seizures, shall not be
violated, and no warrants shall issue, but upon probable cause,
supported by oath or affirmation, and particularly describing the
place to be searched, and the persons or things to be seized.

Amendment IV to the Constitution of the United States
--------------------------------------------------------------------------------------------------------------

Reply via email to