0

Im unable to insert multiple records in a single transaction. Im using foreach in mapper and I'm getting incorrect syntax near ','. I googled and found, in sybase it's not possible to insert multiple rows in sybase.

Insert statement looks like:

insert into Student(id,name)
values (1, Jon), (2,mike),(3,sam)

Comma next to value statement, is creating issue.

csaar
  • 530
  • 5
  • 22
  • Possible duplicate of [Inserting Multiple Rows in Sybase ASE](https://stackoverflow.com/questions/24635327/inserting-multiple-rows-in-sybase-ase) – csaar Jul 18 '19 at 09:35
  • Yes, the question is similar to above post. I didn't see appropriate answer. I want to achieve multiple inserts in one transaction in sybase ase – Sai Srinivas Idimadakala Jul 19 '19 at 16:21
  • You can't insert multiple rows in Sybase ASE by using `values`. Only if you already have the data in a table and inserting with `select`. A possible "hack" would be to use `union all`. For instance `insert into Student(id, name) select 1, "Jon" union all select 2, "Mike" union all select 3, "Sam"`. – csaar Jul 22 '19 at 06:34
  • Thanks for your answer. Im using mybatis for persistence and I want to use foreach to insert multiple values in single transaction. – Sai Srinivas Idimadakala Jul 24 '19 at 04:50

0 Answers0