php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75926 DB2 SQL: column name with character "§" returns an error.
Submitted: 2018-02-06 14:27 UTC Modified: -
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: shlomovanunu at roguewave dot com Assigned:
Status: Open Package: ibm_db2 (PECL)
PHP Version: Irrelevant OS: IBM i v7.x
Private report: No CVE-ID: None
 [2018-02-06 14:27 UTC] shlomovanunu at roguewave dot com
Description:
------------
Issue with accessing a legacy db2 database file/table with db2 extension, the table contains column names using the character section code "§". All works on the IBM i green screen and legacy code.
The character is supported with IT language feature QSYS2932.

The problem is when using the select statement with the individual field names...
if called with '* select' - it works:
SELCT * from qgpl.testpf1  - works 
vs. 
SELECT D§FDT, D§FMODU from qgpl.testpf1 - does not work
 
CREATE TABLE qgpl.testpf1 (
  D§ID   VARCHAR(2),
  D§NAME VARCHAR(20),
  D§NUM VARCHAR(20),
  D§MEMO LONG VARCHAR,  
    ); 

Test script:
---------------
<?php

$database = 'XXXXX';
$user = 'XXXXXX'; 
$password = 'XXXXXX';

//Establish connection to database
$conn = db2_pconnect ($database, $user, $password);
if ($conn === false) {
   die("FAIL : Failed to connect to data base server: $database, with user name :  $user and password : $password");
}
else {
   echo "Connection established to database: $database ";
   echo  "<br /><b>The result of the query is:</b>\n" ;
   
   //Statement does not work
   $sql = "SELECT D§ID, D§NAME FROM QGPL.testpf1";

   //Statement works
//$sql = "SELECT * FROM QGPL.testpf1";

$stmt = db2_prepare($conn, $sql);
$result = db2_execute($stmt);

 if ($result) {
        echo "Successfully called." . "</br>";
        
   /*while (($row = db2_fetch_assoc($stmt)) !== false) {
                    print_r($row);
                    echo "</br>";
               } */
        
   
while ($row = db2_fetch_assoc($stmt)) {
	echo "<pre />" ;
   printf ("%-16s %-32s\n", 
       $row['D§ID'], $row['D§NAME']);
	   
}
} }

?>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-27 15:49 UTC] shlomo dot vanunu at roguewave dot com
A workaround for other PECL users. 

Change the PHP script to use the character  "§" instead of "§" . 

(This works on other Italian customer system with CCSID 1144) 
 
$sql = "SELECT D§ID, D§NAME, D§MEMO   FROM QGPL.testpf1";
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 25 12:01:31 2024 UTC