-
-
Save NattyNarwhal/e1209fc967b0f4dcdfba7d2405557077 to your computer and use it in GitHub Desktop.
Reproduction for SQL_NO_TOTAL bug with PDO_ODBC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dbconn = new PDO("odbc:Driver=IBM i Access ODBC Driver;System=system", $user, $password); | |
$sql = "call DBTEST.getCusInfo(?, ?, ?, ?)"; | |
$dbconn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING ); | |
$stmt = $dbconn->prepare($sql); | |
if (($err = $stmt->errorInfo()) && $err[0]) print_r($err); | |
$Customer = new stdClass(); | |
$Customer->ID = 1; | |
$Customer->Data1 = ""; | |
$Customer->Data2 = ""; | |
$Customer->Data3 = 1; | |
$stmt->bindParam(1, $Customer->ID, PDO::PARAM_INT); | |
if (($err = $stmt->errorInfo()) && $err[0]) print_r($err); | |
// Crash occurs when this is 20, instead of 21 (or omitting length) | |
$stmt->bindParam(2, $Customer->Data1, PDO::PARAM_INPUT_OUTPUT | PDO::PARAM_STR, 20); | |
if (($err = $stmt->errorInfo()) && $err[0]) print_r($err); | |
// Crash occurs when this is 25, instead of 26 (or omitting length) | |
$stmt->bindParam(3, $Customer->Data2, PDO::PARAM_INPUT_OUTPUT | PDO::PARAM_STR, 25); | |
if (($err = $stmt->errorInfo()) && $err[0]) print_r($err); | |
$stmt->bindParam(4, $Customer->Data3, PDO::PARAM_INPUT_OUTPUT | PDO::PARAM_INT, 10); | |
if (($err = $stmt->errorInfo()) && $err[0]) print_r($err); | |
$stmt->execute(); | |
if (($err = $stmt->errorInfo()) && $err[0] && ($err[0] != '00000')) print_r($err); | |
var_dump($Customer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
**FREE | |
Ctl-Opt DftActGrp(*No) ActGrp(*New); | |
Dcl-Pi GetCusInfo; | |
pCusID Int(10); | |
pCusName Char(20); | |
pCusEmail Char(25); | |
pCusAge Int(10); | |
END-PI; | |
Select; | |
When (pCusID = 1); | |
pCusName = '5char'; | |
pCusEmail = 'xxxxxxxxxxxxxxxxxxx'; | |
pCusAge = 19; | |
When (pCusID = 2); | |
pcusName = ' 8chars'; | |
pCusEmail = 'xxxxxxxxxxxxxxxxx'; | |
pCusAge = 19; | |
When (pCusID = 3); | |
pcusName = ' 8chars'; | |
pCusEmail = 'xxxxxxxxxxxxxxxx'; | |
pCusAge = 41; | |
When (pCusID = 4); | |
pcusName = '5char'; | |
pCusEmail = 'xxxxxxxxxxxxxxxxx'; | |
pCusAge = 48; | |
ENDSL; | |
*InLR = *On; | |
Return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- SQL is Db2 for i | |
CREATE PROCEDURE DBTEST/GETCUSINFO ( | |
IN CUSID INTEGER , | |
OUT CUSNAME CHAR(20) , | |
OUT CUSEMAIL CHAR(25) , | |
OUT PCUSAGE INTEGER ) | |
LANGUAGE RPGLE | |
SPECIFIC DBTEST/GETCUSINFO | |
NOT DETERMINISTIC | |
MODIFIES SQL DATA | |
CALLED ON NULL INPUT | |
EXTERNAL NAME 'DBTEST/GETCUSINFO' | |
PARAMETER STYLE GENERAL ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment