473,383 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

connect to db2 database using dbi?

I am trying to execute a query on a db2 database using the dbi module. I'm wondering if someone can take a look at my code and tell me what I'm doing wrong. I'm assuming it's a problem with my query, but my query works fine in access, so I don't know. I guess I don't really understand how queries work differently in db2. I typically connect to a sql database.

Here is the error I'm getting:
Couldn't execute query: [IBM][CLI Driver][DB2] SQL0204N "(my userid here).ADXSPIT_SPI_MASTER" is an undefined name. SQLSTATE=42704
(SQL-S0002)(DBD: st_execute/SQLExecute err=-1)

My database name is DDXSPI1D, residing on server DB239. ADXSPIT.ADXSPIT_SPI_MASTER is the table name.

Here is my code:

#!/usr/bin/perl

# Include necessary modules
use CGI;
use CGI::Carp ("fatalsToBrowser");
use IO::File;
use DBI;

# create our CGI
$query = new CGI;

print "Content-Type: text/html\n\n";
print $query->start_html(-title=>"SLA DB2 TEST",);

#Include config and database info
require("../config/slaconfig.txt");

# Get SLA that is passed into this page
$ProjectNum=$query->param('ProjectNum');

# If the ProjectNum is undefined, just print out
# the form to search for a ProjectNum
if ($ProjectNum == undef)
{

print<<EOM;
<body>
<center>
<h1>SLA DB2 Project Test</h1>
<form name="GetProj" method="post" action="../../cgi-bin/lrrform_DB2.pl">
Please enter a Project Number: <input type="text" size="10" name="ProjectNum">
<p><input type="submit" value="Submit">&nbsp;<input type="reset" value="Clear Form">
</p>

</form>
</center>
</body>
</html>
EOM
}
else
{
# Connect to the database
$dbh = DBI->connect("dbi:ODBC:DB239", $PROJUSER, $PROJPassword)
or die "Couldn't connect to database: $DBI::errstr\n";

$DB2Query="SELECT ADXSPIT.PROJECT_NUM, ADXSPIT.PROJECT_NAME, ADXSPIT.PROJECT_DESC FROM ADXSPIT.ADXSPIT_SPI_MASTER where
ADXSPIT.PROJECT_NUM=$ProjectNum;";

#query database
$dbquery=$dbh->prepare($DB2Query) ||
die "Prepare failed: $DBI::errstr\n";

$dbquery->execute() ||
die "Couldn't execute query: $DBI::errstr\n";

$ProjInfo=$dbquery->fetchrow_array;

$dbquery->finish();

#print results
print <<EOM;
<body>
<center>
<h1>SLA DB2 Project Test RESULTS</h1>
This is cool!
</p>

</form>
</center>
</body>
</html>
EOM
print $ProjInfo;
}

Jul 19 '05 #1
0 4595

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Mr Dygi | last post by:
Hi, PHP 4.3.4 installed manually from package *.zip and Apache 2. I have a problem with this simple code: <?php $link = mysql_connect("127.0.0.1","","") or die("Could not connect: " ....
1
by: DAVID | last post by:
Hello, With regards to the Connect dialog on Oracle forms 6i via which we can connect to Oracle database, should we use the same functionality on forms run time again? I mean, I want to make a...
6
by: Jeff Sandler | last post by:
I have a database I created in mySQL. I've been entering data every day into the database using a Java application that I wrote. The database and the Java program are on the same Win 98 SE...
3
by: Lee | last post by:
Hi, I'm developing a socket program to connect to Informix database through the ODBC. In here i called my socket program as "tap" . My tap will listen for data from unix through port 1070. After...
4
by: banz | last post by:
Hello I have a problem to resolve: I wrote a Perlscript which caches data from a server (local on my machine) I would like to have a other connection to a remote server but I don't know how to...
5
by: rAinDeEr | last post by:
Hi, Y'day one of my friend showed me how to connect to a Oracle database as SYSDBA, DBA etc I have DB2 UDB installed in Linux machine.Right now, I have a user WADI which has got some...
1
by: GNoter | last post by:
Scenario: I've a WebFarm with 2 web servers which are NLBs (network load balanced). Web1 and Web2; they are not part of a domain. I have a third server, Server3, which is part of a domain and on...
2
by: jeffhan | last post by:
we have os/400 db2 database at the backend. i installed db2 v9 connect server on one windows server which is locating the same network with database server. now how to i configure the connect...
6
by: Al G | last post by:
Can someone tell me what I need to get connected to our AS400? I am trying to write an app in VS2005(Data source, Gridview) that requires data from files on our AS400. I've downloaded DB2, and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.