Troubleshooting
Problem
An "SQL 418" error occurs in IBM® Rational® Business Developer while debugging or running an EGL [] get[] statement using a []#sql[] directive containing a call to the IBM DB2® []TIMESTAMP[] function. This technote explains this error's cause and suggests a couple of solutions.
Symptom
The following is a example of the error messages received when the problem occurs:
egl.io.sql.SQLException: EGL0504E GET: DB2 SQL error: SQLCODE: -418, SQLSTATE: 42610,
SQLERRMC: null[sqlstate:42610][sqlcode:-418]
EGL0002I The error occurred in the TestSQL program processing the main2 function.
Cause
This is a known problem when the TIMESTAMP function is used with Host variables, for example:
function main2()
SysLib.writeStdout("start");
rec MYTABLE;
loc_DATE char(10);
loc_DATE = "12.02.2009";
get rec
with #sql{
select * from test.TABLE3
WHERE COL4 > TIMESTAMP(:loc_DATE,'00.00.00')
};
SysLib.writeStdout("end, COL4=" + rec.COL4);
end
Diagnosing The Problem
Use the attached 72519.zip
project interchange file to recreate the error.
Complete the following steps to test for the error.
- Start Rational Business Developer Extension 7.1.0.2
- Import the attached project. To import the attached project, do the following:
- Click Workspace > File > Import > Other > Project Interchange > Next > Browse.
- Select the 72519.zip file from download location
- Click All > Finish.
- Configure the DB2 libraries in according to location your file system.
- Click Workspace > Project(72519EGL).
- Right click Properties > Java Build Path > Libraries > db2jcc.jar, db2jcc_license_cisuz.jar.
- Build the project, if Build automatically is not switched on. Click Workspace > Project > Build Automatically.
- Test the EGL source by debugging. Click Workspace > Project(72519EGL) > EGL Source > test > TestSQL.egl. Right click Debug EGL Program.
Resolving The Problem
To resolve the problem use one of the two following workarounds.
- Use the prepare statement, for example:
prepare stmt1 from "select * from test.TABLE3 WHERE COL4 > TIMESTAMP('::loc_DATE::"', '00.00.00')";
get rec with stmt1;
OR
- Use the EGL timestamp function instead of the DB2 timestamp function, for example:
loc_DATE timeStamp;
loc_DATE = dateTimeLib.timeStampValue("20090212000000");
get rec with #sql{ select * from test.TABLE3
WHERE COL4 > :loc_Date};
Was this topic helpful?
Document Information
Modified date:
02 August 2018
UID
swg21376221