tracker issue : CF-3852375

select a category, or use search below
(searches all categories and all time range)
Title:

DB2 9.7 FP9 Insert Query autogenerated keys retrieval fails with “Element 1 is undefined in RDS” error

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/NotABug

Reporter/Name(from Bugbase): / John Breidenstine (Md. Kaif Akbar Quraishi)

Created: 11/16/2014

Components: Database, JDBC

Versions: 10.0

Failure Type: Non Functioning

Found In Build/Fixed In Build: 10,287689 /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Win All

Vote Count: 0

Problem:

Insert Query autogenerated keys retrieval fails with When DB2 9.7 Fix Pack 9  and throws below error:-
-
Error Occurred While Processing Request
"Element 1 is undefined in RS"
 
The error occurred in C:/ColdFusion10/cfusion/wwwroot/jlb_auto_increment_db2.cfm: line 16

14 : </CFQUERY>
15 :     
16 : <CFSET mandate_hold = rs.1>            
17 :           
18 : <cfoutput> #rs.1# </cfoutput>

Stack Trace
at cfjlb_auto_increment_db22ecfm458941529.runPage(C:/ColdFusion10/cfusion/wwwroot/jlb_auto_increment_db2.cfm:16) 

coldfusion.runtime.UndefinedElementException: Element 1 is undefined in RS.
	at coldfusion.runtime.DotResolver.resolveSplitNameInMap(DotResolver.java:109)
	at coldfusion.runtime.CfJspPage._resolve(CfJspPage.java:1643)
	at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1822)
	at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1815)
	at cfjlb_auto_increment_db22ecfm458941529.runPage(C:\ColdFusion10\cfusion\wwwroot\jlb_auto_increment_db2.cfm:16)
	at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:244)
	at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:444)
	at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
	at coldfusion.filter.IpFilter.invoke(IpFilter.java:64)
	at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:449)
	at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
	at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
	at coldfusion.filter.PathFilter.invoke(PathFilter.java:112)
	at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:94)
	at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:79)
	at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
	at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
	at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:58)
	at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
	at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
	at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62)
	at coldfusion.CfmServlet.service(CfmServlet.java:219)
	at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
	at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:414)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:722)
-

Method:
1) Install DB2 Database version 9.7 Fix Pack 9
2)  Create table with below query:-
CREATE TABLE "LEGTRK  "."JLB_AGKTEST_TBL"  (
                  "COL1" INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (
                    START WITH +1
                    INCREMENT BY +1
                    MINVALUE +1
                    MAXVALUE +2147483647
                    NO CYCLE
                    NO CACHE
                    NO ORDER ) )
                 IN "USERSPACE1" ;

3) Insert few records there by database directly, which is successfully done
4) Install CF10 with all updates
5) Use below CFM page code:-
<CFTRANSACTION action = "begin">
<CFSET mandate_hold = ''>		
<CFQUERY NAME="insertMandate" DATASOURCE="legis" result="rs">            
      INSERT INTO MQURAISH.JLB_AGKTEST_TBL
      (
        COL1
      )
        VALUES
      (
        default
      )
</CFQUERY>
<CFSET mandate_hold = rs.1> 
<cfoutput> #rs# </cfoutput>
</CFTRANSACTION>

6) Get the above mentioned error

Result:
Getting error "Element 1 is undefined in RS."

Expected:
It should return the autogenerated key

Workaround:
When using "other" option for JDBC datasource with DB2 version 9.7 Fix Pack3  resolves this error whereas using DB2 version 9.7 Fix Pack9 there still throw same error.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3852375

External Customer Info:
External Company: LEGISLATIVE DATA PROCESSING
External Customer Name: John Breidenstine
External Customer Email: JBreidenstine@legis.state.pa.us

Attachments:

Comments:

This is an issue with the db2 driver that customer is using and also with the way the cfml code is written. Short story: There is an easy fix. Change the call of rs.1 to rs.generatedkey This is the exact reason why generatedkey was introduced in ColdFusion. Basically the key names of the auto generated keys are returned by the driver and it varies with each driver. DB2 9.7 FP3 was returning "1" as the key name but DB2 9.7 FP9 returns "col1". You can see this by dumping the result object. <cfdump var="#rs#"> You can see the key returned by the driver and also "generatedkey" which ColdFusion populates. So while rs.col1 will work for DB2 9.7 FP9, you should use rs.generatedkey so that you don't have to change this the next time you change the driver.
Comment by Himavanth R.
10073 | December 04, 2014 02:24:49 AM GMT