Define cursor

General discussion on Zend Core for IBM System i

Define cursor

Postby neckrom on Wed Apr 13, 2011 10:29 am

Hi.
I'm new to zend core i5/os, and not very expirenced on IBM iservers, so excuse me if I'm asking a stupid question.

I've PHP installed on our V5R4 server. I'm trying to make a simple query that despite being executed with 'STRSQL' on the OS side, it doesn't on PHP side.

So the query is:
Code: Select all
SELECT table2.key, table2.name FROM table1 LEFT OUTER JOIN table2 ON (table1.key = table2.key) WHERE table1.year = '2011' AND table1.weeknr = '15' GROUP BY table2.key, table2.name


Doing this on the OS side via STRSQL gets executed, but in PHP it returns me an error that I don't know how to get arround:
Code: Select all
Error: Array | Error Message: 36001 | Error number: -243


The connection I've made to connect to the server is as follows:
Code: Select all
$i5_server_ip = "127.0.0.1";
$i5_uname = "username";
$i5_pass = "password";
$i5_database = "DATABASE";
$options = array(
      I5_OPTIONS_JOBNAME      => null,
      I5_OPTIONS_SQLNAMING    => 'SQL',
      I5_OPTIONS_DECIMALPOINT => ',',
      I5_OPTIONS_CODEPAGEFILE => null,
      I5_OPTIONS_LOCALCP=>" UTF-8;ISO8859-1",
      I5_OPTIONS_JOBNAME=>'5JOB',
      I5_OPTIONS_INITLIBL     => $i5_database);
      
/*$db2options = array(
         'cursor' => DB2_SCROLLABLE
         );*/
               
$conn = i5_connect($i5_server_ip, $i5_uname, $i5_pass, $options);
if ($conn === false) {
   echo "APPLICATION PANIC: Failed to connect to server!!!<br/>";
   die("Error: ".i5_error()." | Error Message: ".i5_errormsg()." | Error number:".i5_errno());
}


The error is thrown on the following PHP code:
Code: Select all
$result=i5_query($query_string) or die ("Error: ".i5_error()." | Error Message: ".i5_errormsg()." | Error number: ".i5_errno());


Can anyone help?
Thanks in advance!
neckrom
 
Posts: 1
Joined: Wed Apr 13, 2011 10:04 am

Re: Define cursor

Postby scottgcampbell on Wed Apr 13, 2011 2:35 pm

If you are just getting started you will probably want to switch to ZendServer now, http://www.zend.com/en/products/server/downloads, the CE version is also free.
If you have a lot done you will probably still want to switch but maybe not immediately.

You will probably also want to use the db2* functions instead of the i5* functions.

For example:
Code: Select all
<?php
$condb2 = db2_pconnect ( 'databasename', '', '');
$sql = "SELECT * FROM LIBRARY.FILE";
$query_res = db2_prepare ( $condb2, $sql, array() ) ;
if (! $query_res)
{
   echo ( db2_stmt_error() . " - Query: Prepare error:" . db2_stmt_errormsg ()) ;
   return false ;
}
$qry_err = db2_execute ( $query_res, array() ) ;
if (! $qry_err)
{
   $error = true ;
   
   echo ( "Query: execute error : " . db2_stmt_error () ) ;
   exit;
}
echo "<pre>";
while ( ($row = db2_fetch_array ( $query_res )) )
{   
   print_r( $row ) ;
}
echo "</pre>Done";
?>


Hope that helps.

Scott
scottgcampbell
 
Posts: 187
Joined: Wed Apr 22, 2009 2:29 pm
Location: Edmonton, AB, Canada

Re: Define cursor

Postby erich_hieden on Wed Apr 13, 2011 3:24 pm

According to System i Database SQL messages and codes
Message Text:
SENSITIVE cursor &1 cannot be defined for the specified SELECT statement.
Cause Text:
The cursor &1 is defined as SENSITIVE but the query requires the creation of a temporary result table. A SENSITIVE cursor cannot be implemented.
Recovery Text:
Redefine the cursor as ASENSITIVE or INSENSITIVE or change the query so that it no longer requires the creation of a temporary result table.


Can't tell you anything else about that, since I've never been coming across this error.

Regards
erich_hieden
 
Posts: 393
Joined: Tue Jul 07, 2009 9:01 am


Return to Zend Core for i5/OS

Who is online

Users browsing this forum: No registered users and 1 guest