| Summary: | Provide access to generated keys on SQL ADD operation | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Will Smythe <smythew> |
| Component: | EDT | Assignee: | Joseph Vincens <jvincens> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | jspadea, jvincens, mheitz, svihovec, tww |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
| Bug Depends on: | |||
| Bug Blocks: | 365062 | ||
Setting importance to MAJOR because lack of this function makes it *very* difficult (if not impossible) to acquire a generated ID for a record added via the ADD. changed from defect to Enhancement. Set priority to P1 to indicate that this is a request to be implemented in 070. We will need to evaluate for cost/risk. Discussed with Brian & Jing - too late to add new enhancements for 070. This would be functionality beyond what is in RBD, and in general we are deferring all such requests to 1.0. Also, the developer who needs to implement this is out of the office this week. Until this is implemented the following will return the generated values
idRec annotatedTblRec ;
get idRec.id from ds with
#sql{
select IDENTITY_VAL_LOCAL() from ANNOTATEDTBL
} ;
This is a necessary capability. .. without it, developers have to play tricks/games in their code. We will try to look at this one early in the FVT week for I3. This will only work when a record/handler is specified, it will not work with scalars. close |
@GeneratedValue is a nice addition (avoids custom SQL for ADD on tables that have auto-generated fields), but developers need the ability to access the ID(s) generated when a new record is added to the SQL data source. The "add" statement correctly avoids trying to insert a value for @generatedvalue fields, but this statement should either return (somehow) any generated keys OR - even better - set them directly in the record that was the source record of the action. Example record: record Customer type Entity { @table { name = "customer" } } id string{@id, @generatedvalue}; name string? end Simple add code (works correctly): a Customer { name = "My Company Name" }; add a to ds; Database table after add: | ID | Name | | 331 | My Company Name | Note record "a" still has 0 set as its ID a.name = "Updated company name"; replace a to ds; /// PROBLEM: no easy way to update this record since it doesn't have the correct ID set on it (probably still set to 0). Need for it to get set to ====================== I think it is logical for the ADD statement to update the values of any @generatedvalue fields in a record that was added. This way the record will have the correct (generated) value set for its ID after the ADD statement returns. Btw, see JDBC reference: http://download.oracle.com/javase/1.4.2/docs/api/java/sql/Statement.html#getGeneratedKeys() Collapse All Comments Expand All