tsilb
tsilb

Reputation: 8037

DB2 Equivalent to SQL's GO?

I have written a DB2 query to do the following:

In MSSQL, I am allowed to run the commands one after another as one long query. Failing that, I can delimit them with 'GO' commands. When I attempt this in DB2, I get the error:

DB2CLI.DLL: ERROR [42601] [IBM][CLI Driver][DB2] SQL0199N The use of the reserved
word "GO" following "" is not valid. Expected tokens may include: "". 
SQLSTATE=42601 

What can I use to delimit these instructions without the temp table going out of scope?

Upvotes: 2

Views: 4962

Answers (3)

Matthew Vines
Matthew Vines

Reputation: 27561

I would try wrapping what you are looking to do in BEGIN and END to set the scope.

GO is not a SQL command, it's not even a TSQL command. It is an instruction for the parser. I don't know DB2, but I would imagine that GO is not neccessary.

From Devx.com Tips

Although GO is not a T-SQL statement, it is often used in T-SQL code and unless you know what it is it can be a mystery. So what is its purpose? Well, it causes all statements from the beginning of the script or the last GO statement (whichever is closer) to be compiled into one execution plan and sent to the server independent of any other batches.

Upvotes: 1

cjk
cjk

Reputation: 46435

GO is something that is used in MSSQL Studio, I have my own app for running upates into live and use "GO" to break the statements apart.

Does DB2 support the semi-colon (;)? This is a standard delimiter in many SQL implementations.

Upvotes: 4

Scott Ivey
Scott Ivey

Reputation: 41568

have you tried using just a semi-colon instead of "GO"?

This link suggests that the semi-colon should work for DB2 - http://www.scribd.com/doc/16640/IBM-DB2

Upvotes: 1

Related Questions