3

I have added / character as statement terminator all in my db2 statements. I can run sql file in data studio client without any issue. But when I run the sql file in db2 command prompt by issuing db2 -tsvf db2.sql command I got

DB21007E End of file reached while reading the command.

error. I could resolve this issue by changing statement terminator character from / to ;. My question is should I keep statement terminator character as / or ;? If I keep /, is there any way to run sql file from command line also?

mustaccio
28.7k24 gold badges60 silver badges77 bronze badges
asked Dec 2, 2015 at 10:32
0

2 Answers 2

6

You would need to use the -td<statement terminator> syntax. So you would need to format the above as follows:

db2 -td/ -svf db2.sql

This would tell DB2 that your statement terminator is the / character, otherwise, yes the default is the semicolon ;.

answered Dec 2, 2015 at 13:58
0

You can also set the terminator in the file itself, by adding this comment as the first line like a shebang

--#SET TERMINATOR /
answered Dec 14, 2022 at 14:26
1
  • Technically speaking, it doesn't need to be the first line, as long as it comes before the statements that use that character as a terminator. Commented Dec 14, 2022 at 14:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.