Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 360103

Summary: No default statement generated for replace record to resultset
Product: z_Archived Reporter: Paul Hoffman <hoffmanp>
Component: EDTAssignee: Project Inbox <edt.javagen-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: chenzhh, jvincens
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Test case
none
Supporting library for loading db / table
none
Replaces.egl none

Description Paul Hoffman CLA 2011-10-06 10:23:43 EDT
Created attachment 204671 [details]
Test case

No default statement generated for replace record to resultset.  Instead the EGL compiler reports the following errors for the line:

Description	Resource	Path	Location	Type
IWN.JavaGen.9998.e 30/811 Exception occurred: java.lang.ClassCastException: org.eclipse.edt.mof.egl.impl.MemberNameImpl cannot be cast to org.eclipse.edt.mof.egl.EGLClass	NoDefaultSQLForReplaceToResultSet.egl	/test.edt.sql.test/EGLSource/sql/test/defects	line 30	EDT Generation Problem
IWN.JavaGen.9999.e 30/811 Stack Trace: java.lang.ClassCastException: org.eclipse.edt.mof.egl.impl.MemberNameImpl cannot be cast to org.eclipse.edt.mof.egl.EGLClass	NoDefaultSQLForReplaceToResultSet.egl	/test.edt.sql.test/EGLSource/sql/test/defects	line 30	EDT Generation Problem
Comment 1 Paul Hoffman CLA 2011-10-06 10:24:29 EDT
Created attachment 204672 [details]
Supporting library for loading db / table
Comment 2 Justin Spadea CLA 2011-10-13 10:51:53 EDT
Joe - this is a generation defect. The replace statement that's failing is valid according to the spec.
Comment 3 Joseph Vincens CLA 2011-10-14 15:41:15 EDT
fixed
after making the fix I had a couple of problems.
There are rules using FOR UPDATE with derby: http://db.apache.org/derby/docs/10.1/ref/rrefsqlj41360.html#rrefsqlj41360__sqlj15384

-Since we only allow the record all columns must be listed in the FOR UPDATE (so I just removed the columns, the default is all).
-Order by is not allowed
-I had to set the concurrency in the RS to CONCUR_UPDATABLE, scrollablity remained as the default forward only.


This change also fixes another EGL file I got from you:Replaces.egl, but I don't remember the defect # and I can't find a way to search for an attachment. I've attached it because it's similar to the attached test, but it doesn't use FOR UPDATE, it uses a scrollable updateable cursor, and just replaces values on the result set.
Comment 4 Joseph Vincens CLA 2011-10-14 15:42:05 EDT
Created attachment 205232 [details]
Replaces.egl
Comment 5 Paul Hoffman CLA 2011-10-24 11:32:47 EDT
Replace to result set has a design problem.   It's implementation works only with row records and is inconsistent with the implementation of the other statements.

Consider the open from result set:   No default SQL statement is created for a select for update.   You have to code the required for update of clause by hand.   Typically the developer would not include the record key in the for update of columns.

Compare the replace to result set statement.   The DB manager will require the columns replaced to match the for update of list in the select.  However replace to result set ( unlike replace to data source ) does not provide any way of specifying the column list other than inferring it from a row or entity.   This means the developer must either include all columns in the row in the for update clause on the select, or provide an alternate row record or entity for used in the replace to result set statement.

For consistency with the rest of the statements, you could support

replace a, b, c to rs ;

like you do with add.
Comment 6 Joseph Vincens CLA 2011-10-26 10:10:28 EDT
I talked with Tim and we agree in principal with what you are saying, but before we rush into a design we should review the proposed and make sure it's feasible. Since we are pretty much out of time for 0.7.0 I have opened a 1.0 enhancement (362073) with your comments.
Comment 7 Paul Hoffman CLA 2011-10-26 12:42:27 EDT
Closed since enhancement opened for 1.0
Comment 8 Paul Hoffman CLA 2011-10-26 12:46:01 EDT
Forgot to change status after previous comment.