db2_fetch_row fails ... no idea why?

General discussion on Zend Server for IBM System i

db2_fetch_row fails ... no idea why?

Postby greg7308 on Wed Mar 02, 2016 11:14 pm

I have a PHP script which has two parts, both parts use SQL to retrieve data from tables on the same LPAR. Part 1 works, Part 2 does not return a valid array/row which is somewhat vexing.

As they use the same connection then it stands to reason that the database (lpar name), userid (blank), password (blank) etc are correct as the results of the part1 query are correctly displayed to the screen.

Part 2 I am checking a file in BRMS to find control group names used past a certain timestamp. The SQL (which is echoed to screen for debug) works perfectly when done via STRSQL interface.

When i incomment in the debuggy echo statements it shows that the db2_prepare and db2_execute statements are valid and returns a valid resource etc, but I am always getting the uh oh response.

The db2_stmt_errormsg is displayed as "[]" ie no content.

Our audit logs do not show any auth issues, and the objects in question have public(*USE)

Any ideas?
GC

Code: Select all
$user='';   $pass='';   $opts = array("i5_naming"=>DB2_I5_NAMING_ON, "i5_commit"=>DB2_I5_TXN_NO_COMMIT);
$brms_conn = db2_connect($cursys, $user, $pass, $opts);
$SQL = "select distinct bkhgrp from qusrbrm/qa1ahs where trim(bkdkmain) >= '$maxendtime'";
$Stmt = db2_prepare($brms_conn, $SQL);
   //if (!$Stmt) { echo "db2_prepare: FAIL [$Stmt]<br />"; } else { echo "db2_prepare: OK [$Stmt]<br />"; }
//$result = db2_execute($Stmt);
   //   if (!$result) { echo "db2_execute: FAIL [$result]<br />"; } else { echo "db2_execute: OK [$result]<br />"; }
db2_execute($Stmt);
echo "exec errormsg: [" .db2_stmt_errormsg($Stmt)."]<br />";
if(db2_fetch_row($Stmt)) {
   do {
      $Ctrl_Group = db2_result($Stmt, 0);
      echo "<tr>";
        echo "<td>$cursys</td>";
        echo "<td>$Ctrl_Group</td>";
      echo "</tr>";
   } while (db2_fetch_row($Stmt));
}  else {
   echo "uh oh";
}
greg7308
 
Posts: 23
Joined: Fri Mar 28, 2014 1:28 am

Re: db2_fetch_row fails ... no idea why?

Postby greg7308 on Wed Mar 02, 2016 11:51 pm

*GROAN*

The BRMS file has CCSID 65535, whereas the file in part1 has a CCSID of 37.

it does NOT report any error on the 65535 thing which is damn vexing ...
greg7308
 
Posts: 23
Joined: Fri Mar 28, 2014 1:28 am

Re: db2_fetch_row fails ... no idea why?

Postby greg7308 on Thu Mar 03, 2016 12:06 am

So new question - does anyone know a way using SQL to convert the CCSID as part of the select statement. I did try db2_fetch_array also but no luck.

Eureka! This does it ... :o)

CAST(bkhgrp AS CHAR(10) CCSID 37) as goat

Code: Select all
   $SQL = "select distinct CAST(bkhgrp AS CHAR(10) CCSID 37) as goat from qusrbrm/qa1ahs where trim(bkdkmain) >= '$maxendtime'";
greg7308
 
Posts: 23
Joined: Fri Mar 28, 2014 1:28 am

Re: db2_fetch_row fails ... no idea why?

Postby teen4946 on Wed Jun 22, 2016 7:45 am

Use db2_fetch_row() to iterate through a result set, or to point to a specific row in a result set if you requested a scrollable cursor.I read it in an article. PHP is simple language.dissertation is document submitted in support for applicant for an academic degree or any other course professional qualification presenting the writers study and finding.

essay topics for high school students
teen4946
 
Posts: 1
Joined: Wed Jun 22, 2016 7:38 am

Re: db2_fetch_row fails ... no idea why?

Postby rebe5630 on Thu Jul 06, 2017 3:08 am

I don't know who you are. Don't even know your name I wish we could talk but I don't have a number to call. So hold your hand up if you hear me, I've been searching but all that I found Is everywhere that I go, is standing alone in the crowd Maybe you're right here in front of me Am I looking too hard, it's hard to see Oh, give me a sign; I'm starting to wonder if you've lost your way I've been right here waiting patiently, Your lane should be right here next to me I need you tonight, think of you all of the time. thank you
rebe5630
 
Posts: 1
Joined: Thu Jul 06, 2017 3:07 am


Return to Zend Server for IBM i

Who is online

Users browsing this forum: No registered users and 3 guests

cron