Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

db2 -tvf <script> causes SQL0104N

Status
Not open for further replies.
Aug 13, 2003
1
US
I am calling a script using db2 -tvf <script name> from the command line (UNIX); in the script I am mixing DB2 commands with OS commands e.g. pipes such as
list node directory > node.txt;
The line is interpreted as a DB2 command, resulting in &quot;An unexpected token &quot;>&quot; was found following &quot;directory&quot;. expected tokens may include: &quot;END-OF-STATEMENT&quot;. SQLSTATE=42601&quot;
Setting the whole up as an executable is not an option. Does anyone know what the syntax is to avoid the SQL0104N?
 
Layne,

would you not be better having a script which calls a number of DB2 scripts. I think the problem you've got is it's just expecting valid db2 commands without any operating system calls.

What I'm thinking is you could have something along the lines of

$ db2 -tvf file1 > outfile1

$ db2 -tvf file2 > outfile2

Where each file contains 1 or more of your commands.

example

connect to mydatabase;
list database directory;
create table first (t1 INT);
insert into first values(1);
select * from first;
connect reset;
terminate;


Thanks
Greg
 
Alternatively you could try a script which simply asks db2 to do something on each line. In this instance you would simply run the file in the normal manner, ie by typing in its name rather than using db2 -tvf.

Typical entries in the file would be

db2 list node directory > node.txt

That way you are running an operating system file which just happens to interact with DB2.

Cheers
Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top