DB 2 Regs

(click to open)

Quick Page Table of Contents

Scanning…

PHP DB2 Special registers

[goto main page]

[goto document links]

[goto XMLSERVICE links]

Setting and getting special registers …

<?php
$db2Connection = db2_connect( '*LOCAL', 'DB2', 'MYPWD');
if (!$db2Connection) { echo "false - Connection failed";exit(); }

$sql = "DROP PROCEDURE SET_CLIENT_INFO";
$stmt = db2_exec($db2Connection,$sql);

$sql = "
CREATE PROCEDURE SET_CLIENT_INFO ( 
	IN CLIENT_USERID     VARCHAR(255),
	IN CLIENT_WRKSTNNAME VARCHAR(255),
	IN CLIENT_APPLNAME   VARCHAR(255),
	IN CLIENT_ACCTSTR    VARCHAR(255),
	IN CLIENT_PROGRAMID  VARCHAR(255))
LANGUAGE C
NOT DETERMINISTIC
READS SQL DATA
CALLED ON NULL INPUT
EXTERNAL NAME 'QSYS/QSQAPIS(SETCLIENT)'
PARAMETER STYLE DB2SQL";
$stmt = db2_exec($db2Connection,$sql);

$client = array('billy','bob','thorton','angelina','jolie');
$sql = "CALL SET_CLIENT_INFO(?,?,?,?,?)";
$stmt = db2_prepare($db2Connection,$sql);
$ret=db2_execute($stmt,$client);

$sql="
SELECT CURRENT CLIENT_ACCTNG AS ACCOUNTINGSTRINGSPCREG,
CURRENT CLIENT_APPLNAME AS APPLICATIONNAMESPCREG,
CURRENT CLIENT_PROGRAMID AS CLIENTPROGRAMIDSPCREG,
CURRENT CLIENT_USERID AS CLIENTUSERIDSPCREG,
CURRENT CLIENT_WRKSTNNAME AS WORKSTATIONNAMESPCREG,
CURRENT_DATE AS CURRENTDATESPCREG,
CURRENT DEBUG MODE AS DEBUGMODESPCREG,
CURRENT DECFLOAT ROUNDING MODE AS DECROUNDINGMODESPCREG,
CURRENT DEGREE AS DEGREEOFIOOFSMPSPCREG,
CURRENT_PATH AS PATHFORUNQUALIFIEDNAMESSPCREG,
CURRENT_SCHEMA AS CURRENTSCHEMASPCREG,
CURRENT_SERVER AS CURRENTSERVERSPCREG,
CURRENT_TIME AS CURRENTTIMESPCREG,
CURRENT_TIMESTAMP AS CURRENTTIMESTAMPSPCREG,
CURRENT_TIMEZONE AS CURRENTTIMEZONESPCREG,
SESSION_USER AS SESSIONUSRSPCREG,
USER AS USERVALUESPCREG,
SYSTEM_USER AS SYSTEMUSERSPCREG
FROM SYSIBM.SYSDUMMY1";
$stmt = db2_exec($db2Connection,$sql);
$row = db2_fetch_assoc($stmt) ;
if (!$row) { echo "false - Problem retrieving Special Registers via PHP CLI";exit(); }
var_dump($row);
exit(0);
?>