If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > db2_prepare error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-27-09, 10:40
tdavis tdavis is offline
Registered User
 
Join Date: Mar 2009
Posts: 6
db2_prepare error

Where can I go to decipher PHP errors messages; specifically, the db2_prepare and db2_bind_param have such generic message, and I am just not experienced enough to know what they mean.

Here is my code:
Code:
// Parse work order number //
$account = "";
$account = $_GET['account'];

// Set up SQL statement //
$sql = 'SELECT ODWONR, ODSYSN, ODSVCD, ODSTYP FROM worddpl2 WHERE ODWONR = ?';
$stmt = db2_prepare($conn, $sql);

// Bind parameters //
db2_bind_param($stmt, 1, "account", DB2_PARAM_IN);

// Execute and display SQL results //
if (db2_execute($stmt)) {
   while ($row = db2_fetch_array($stmt)) {
       print "{$row[0]}, {$row[1]}, {$row[2]}, {$row[3]} \n";
   }
}
It is generating this error message:

Warning: db2_prepare() [function.db2-prepare]: Statement Prepare Failed in /www/zendcore/htdocs/cox/query_workorder.php on line 38

If fails, but why?
Reply With Quote
  #2 (permalink)  
Old 04-27-09, 13:07
tdavis tdavis is offline
Registered User
 
Join Date: Mar 2009
Posts: 6
I got it working by hard-coding the library name. Does anyone out there have anything similar to this? Why doesn't the SQL use the jobs library list to find the file?

Code:
$sql = 'Select odcnbr, odwonr, odsysn, odsvcd, odstyp FROM PHXQACMF.worddpl2 Where odcnbr = ?';
Reply With Quote
  #3 (permalink)  
Old 04-28-09, 03:58
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
if you are connected to db with usera it will prefix all objects with usera if not specified. hence the error, because the object does not exists
always specify the complete schema.name
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #4 (permalink)  
Old 04-28-09, 08:15
tdavis tdavis is offline
Registered User
 
Join Date: Mar 2009
Posts: 6
Hard coding is not possible. The file may reside in any number of different libraries, depending on the site that the account exists in. I am going to guess that I have to go another route, a stored procedure possibly? I also read that the Zend tools do allow this; the i5_ equivalents of db2_, but I dont want to go back and forth between the two (seems like db2_ tools are eaiser to use).

Thanks for the response...
-tdavis
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On