This topic is locked

Error trying to run sql or query on DB2 connection

12/22/2021 8:12:04 PM
PHPRunner General questions
J
jmartin17 author

**I need to use client which is keyed in on the screen and have the
CNAME from the JMALIB.MCLIENT before adding to table JMALIB.VALNOT. I created a snippet with the event on change to trigger // run SQL Query to retrieve Client Name
$result["CNAME"] = DBLookup("select CLIENT, CNAME from
JMALIB.MCLIENT where
JMALIB.CLIENT=".$params["CLIENT"]);
$result["CNAME"] = DBLookup("select CLIENT, CNAME from JMALIB.MCLIENT
where CLIENT ='JMALIB.MCLIENT'"); //$sub = DBLookup("select
max(substring(SubID,3,2))+1 from apps_sub_categories where
left(SubID,2)='".$params["val"]."'");
//$result["newCat"] = $params["val"].str_pad($sub,2,"0",STR_PAD_LEFT);
echo $CNAME;
2. To get record from JMALIB.MCLIENT and display CNAME on screen to validate CLIENT
I get this error:

php error happened
Technical information
Error type
256
Error description
[IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0104 - Token was not valid. Valid tokens: ( TABLE LATERAL <IDENTIFIER . URL localhost/buttonhandler.php? Error file C:\Projects\Valnot\output\connections\Connection.php Error line 668 SQL query select CLIENT, CNAME fromJMALIB.MCLIENT` where JMALIB.CLIENT= More
info Call stack
File: line
Function
Arguments

0

connections\Connection.php:668
Connection- triggerError
0. [IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0104 - Token was not valid. Valid tokens: ( TABLE LATERAL <IDENTIFIER . **** #1 connections\ODBCConnection.php:75 ODBCConnection- query 0. select CLIENT, CNAME fromJMALIB.MCLIENT` where JMALIB.CLIENT=

2

include\dal.php:37
DBLookup
0. select CLIENT, CNAME from JMALIB.MCLIENT where JMALIB.CLIENT=

3

buttonhandler.php:87
fieldEventHandler_CLIENT_event
0. Array
(
[table]= JMALIB.VALNOT
[field]= CLIENT
[page]= add
[masterTable]=
[masterKeys]= Array
[keys]= Array
[isManyKeys]=
[location]= add
)

4

buttonhandler.php:54
Global scope
N/A
I tried to purchased two hours of support but it did not seem to update? Can you check and see if it processed?
James
James R. Martin
J. Martin Associates
5185 Tara Ln., Bossier City, LA 71111 - 7810
Phone: (318) 752-4109 Cell Phone: ( 318) 773-9484
e-mail:
jmartin@jmartinassociates.net
**

Sergey Kornilov admin 12/22/2021

James,

are you receiving our emails. You asked the same question directly a few days ago and we have answered it. There are two issues here:

  1. You use DB2 database but your table/field wrappers are for MySQL (backtics). This won't work.
  2. $params["CLIENT"] is empty which breaks the SQL query. You need to make sure that you actually pass something from ClientBefore to Server event of your button. The complete code of both events will help.