Reputation: 494
I know that "Batch Processing allows us to group related SQL statements into a batch and submit them with one call to the database". But my question is how to execute different SQL statements at once i.e I want to insert records to Employee table, Address table , Department table with one call to database. So, is it possible? I'm using PostgreSQL and java.
Upvotes: 0
Views: 71
Reputation: 425073
You can't insert into multiple tables in one statement, but you can do it effectively "at once" by using a transaction:
begin;
insert into table1 ...;
insert into table2 ...;
insert into table3 ...;
commit;
All statements within the transaction (between begin
and commit
) are treated atomically - ie as if they are "one statement".
Upvotes: 1
Reputation: 36987
Group those statements into an anonymous code block and execute that.
See http://nixmash.com/postgresql/using-postgresql-anonymous-code-blocks/
Upvotes: 1