begin atomic
insert into test1 values('1');
insert into test1 values('2');
insert into test1 values('3');
end
it works. Butbegin atomic create table test2(col1 integer); create table test3(col1 integer); enddoes not... My statement terminator is '@'.
Requires Free Membership to View
When you register, you’ll also receive targeted alerts from my team of editorial writers and independent industry experts with the latest news, tips, and advice to help you do your job more efficiently and effectively. Our goal is to keep you informed on the hottest topics and biggest challenges faced by IT professionals today working with data center technologies.
Margie Semilof, Editorial DirectorCompound SQL - that is SQL between a BEGIN ATOMIC and an END - causes either all of the statements to successfully execute or none of the statements to successfully execute. But DB2 limits the type of SQL that can be placed in a compound SQL statement. As you have found, DDL is not permitted.
The following list of SQL-control-statements can be used within the dynamic compound statement:
- FOR Statement
- GET DIAGNOSTICS Statement
- IF Statement
- ITERATE Statement
- LEAVE Statement
- SIGNAL Statement
- WHILE Statement
- fullselect
- Searched UPDATE
- Searched DELETE
- INSERT
- SET variable statement
For More Information
- Dozens more answers to tough DB2 questions from Craig Mullins are available.
- The Best IBM DB2 Web Links: tips, tutorials, scripts, and more.
- Have a DB2 tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical DB2 questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, SQL Server, DB2, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
This was first published in November 2005
Data Center Strategies for the CIO