IBM DB2 help: How do I run multiple-line commands from the UNIX command shell?

yllus

Elite Member & Lifer
Aug 20, 2000
20,577
432
126
I'd like to execute the following SQL, along with a bunch of other table definitions, in IBM DB2. The problem is I have to do it from the *NIX command line, and DB2 doesn't seem to wait for a semicolon to execute a command. Is there a way around this?

--

CREATE TABLE employee
(emp_num INTEGER GENERATED ALWAYS AS IDENTITY,
emp_lastname VARCHAR(50),
emp_firstname VARCHAR(50),
emp_sin INTEGER,
emp_phonenum INTEGER,
emp_emergphonenum INTEGER,
emp_address VARCHAR(100))
 

ggavinmoss

Diamond Member
Apr 20, 2001
4,798
1
0
How about "GO"? Some command line DB programs waith for that as a statement seperator.

-geoff
 

yllus

Elite Member & Lifer
Aug 20, 2000
20,577
432
126
Originally posted by: ggavinmoss
How about "GO"? Some command line DB programs waith for that as a statement seperator.

-geoff
I'd like to set an option to make it wait for me to specify I want it to execute, but it executes anytime I press Enter anyways!
Originally posted by: Ameesh
ummm, put it all on one line?
Doable of course, but really I shouldn't have to do something as lame as that. :p
 

ggavinmoss

Diamond Member
Apr 20, 2001
4,798
1
0
Oh. Try "\" at the end of every line -- I think it lets the shell know you're going to type more.

I could be wrong though.

-geoff
 

yllus

Elite Member & Lifer
Aug 20, 2000
20,577
432
126
Well slap my ass and call me Tinklebell. I found an option that lets me set the semicolon, or anything else, as a statement termination character...

DB2 -t Set statement termination character OFF

Example usage (from the *NIX command shell):

db2 -t ;

The above sets the termination character to the semicolon.