aspose file tools*
The moose likes Spring and the fly likes Declaring variable in Spring batch update SQL query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Declaring variable in Spring batch update SQL query" Watch "Declaring variable in Spring batch update SQL query" New topic
Forums: JDBC Spring
Author

Declaring variable in Spring batch update SQL query

Abhishekshri Shrivastava
Ranch Hand

Joined: Jan 13, 2011
Posts: 31
I have to execute a batchupdate for sybase in spring java. I am using NamedParameterJdbcTemplate for that.
I have to use a variable in SQL to check return value. e.g. SQL -->



above query works fine for single update but issue come in case of batchupdate. I see below error and it's expected in case of batchupdate for the query. I wanted to know what should be the approach to do such kind of operation for a batch update (how to use a variable).

BatchUpdateException: Error occurred while executing batch statement: The variable name '@r' has already been declared. Variable names must be unique within a query batch or stored procedure.
; nested exception is com.sybase.jdbc3.jdbc.SybBatchUpdateException: JZ0BE: BatchUpdateException: Error occurred while executing batch statement: The variable name '@r' has already been declared. Variable names must be unique within a query batch or stored procedure.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Declaring variable in Spring batch update SQL query