dbTalk Databases Forums  

Re: Multi command files and running them from the command prompt

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss Re: Multi command files and running them from the command prompt in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mark Yudkin
 
Posts: n/a

Default Re: Multi command files and running them from the command prompt - 08-18-2003 , 02:04 AM






Use the -td§ option [where § is the desired character]. Details are in the
section titled Command Line Processor Options in the Command Reference.

"Derek Clarkson" <dclarkson (AT) waterwerks (DOT) com.au> wrote

Quote:
Hello,
I have a problem. I have a number of functions which I need to
load.
However these functions contain embedded semi-colons. For example

(1) CREATE FUNCTION REVERSE(INSTR VARCHAR(4000)) RETURNS VARCHAR(4000)
(2) begin atomic
(3) return 'ABC';
(4) end

The problem is that if I have a .sql file containing this function and run
it like this:

db2 -t -f script.sql

Then db2 gets to the semi-colon at the end of line 3 and assumes it is the
end of the create function command. Which generates an error. If I run the
script without the -t flag then DB2 gets to the end of the first line and
assumes thats it, resulting in another error.

The only way we have found to run this is to apply back slashes to each
line, resulting in:

(1) CREATE FUNCTION REVERSE(INSTR VARCHAR(4000)) RETURNS VARCHAR(4000) \
(2) begin atomic \
(3) return 'ABC'; \
(4) end

Our preferred way would be to not have the back slashes and use
semi-colons
to delimit commands. However the DB2 interpreter seems to not be able to
handle nested statements in functions like this.

How have you guys handled this situation ? any thoughts or experience
would
be appreciated.

cio
Derek.



Reply With Quote
  #2  
Old   
Derek Clarkson
 
Posts: n/a

Default Re: Multi command files and running them from the command prompt - 08-18-2003 , 09:26 PM






Thanks guys, -td@ worked just fine.

cio
Derek.

Derek Clarkson wrote:

Quote:
Hello,
I have a problem. I have a number of functions which I need to
load.
However these functions contain embedded semi-colons. For example

(1) CREATE FUNCTION REVERSE(INSTR VARCHAR(4000)) RETURNS VARCHAR(4000)
(2) begin atomic
(3) return 'ABC';
(4) end

The problem is that if I have a .sql file containing this function and run
it like this:

db2 -t -f script.sql

Then db2 gets to the semi-colon at the end of line 3 and assumes it is the
end of the create function command. Which generates an error. If I run the
script without the -t flag then DB2 gets to the end of the first line and
assumes thats it, resulting in another error.

The only way we have found to run this is to apply back slashes to each
line, resulting in:

(1) CREATE FUNCTION REVERSE(INSTR VARCHAR(4000)) RETURNS VARCHAR(4000) \
(2) begin atomic \
(3) return 'ABC'; \
(4) end

Our preferred way would be to not have the back slashes and use
semi-colons to delimit commands. However the DB2 interpreter seems to not
be able to handle nested statements in functions like this.

How have you guys handled this situation ? any thoughts or experience
would be appreciated.

cio
Derek.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.