If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Termination Characters

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-07-03, 15:44
ansonee ansonee is offline
Registered User
 
Join Date: Feb 2002
Location: Minneapolis, MN
Posts: 253
Termination Characters

I'm at thwe end of my rope. Hopefully someone can provide some direction....

I'm trying to run just a basic SQL script:

DECLARE @intPower INTEGER
DECLARE @intCounter INTEGER
DECLARE @intBITMAP INTEGER
SET @intCounter = 0;
WHILE @intCounter <= 10
BEGIN
SELECT @intPower = POWER(2,@intCounter);
SELECT @intBITMAP = db2admin.BITAND(256, @intPower);
IF @intBITMAP = @intPower
BEGIN
SELECT VALUES @intBITMAP;
END

SET @intCounter = @intCounter + 1;
END

The problem I'm getting is with the statement termination character. I've tried running it with the semi-colon turned off and kept getting the "End of file reached error". When I run the script above I get the "Unexpected token END-OF-STATEMENT" error.

Please help - I'm sure I'm missing something very obvious.

Thanks!

Anthony




--select 79 & 64
__________________
Anthony Robinson

"If I'm curt with you, it's because time is a factor here. I think fast, I talk fast, and I need you guys to act fast if you want to get out of this. So, pretty please - with sugar on top..."
Reply With Quote
  #2 (permalink)  
Old 11-07-03, 17:19
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Re: Termination Characters

The normal practice when writing SQL PL (like Triggers, stored procs etc) is to have @ as the delimiter because ; is the default one for PL ..

In that case, we do

CREATE PROCEDURE ....
------
-------
SELECT col1 into :abc from tab1 ;
-----
----
END @

,save in a file file1.sql and do
db2 -td@ -f file1.sql

td@ indicates that the deliniter is semi-colon ...

I'm sure you can apply this explanation to your scenario

Sathyaram


Quote:
Originally posted by ansonee
I'm at thwe end of my rope. Hopefully someone can provide some direction....

I'm trying to run just a basic SQL script:

DECLARE @intPower INTEGER
DECLARE @intCounter INTEGER
DECLARE @intBITMAP INTEGER
SET @intCounter = 0;
WHILE @intCounter <= 10
BEGIN
SELECT @intPower = POWER(2,@intCounter);
SELECT @intBITMAP = db2admin.BITAND(256, @intPower);
IF @intBITMAP = @intPower
BEGIN
SELECT VALUES @intBITMAP;
END

SET @intCounter = @intCounter + 1;
END

The problem I'm getting is with the statement termination character. I've tried running it with the semi-colon turned off and kept getting the "End of file reached error". When I run the script above I get the "Unexpected token END-OF-STATEMENT" error.

Please help - I'm sure I'm missing something very obvious.

Thanks!

Anthony




--select 79 & 64
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 12-22-03, 11:52
dvillani dvillani is offline
Registered User
 
Join Date: Aug 2003
Location: Italy
Posts: 33
Is there a way to set the delimiter character in the script itself?
Example:

Select * from employee;
------
-----
set delimiter = @

begin atomic
for c1 as
select code as cd from codes
do
insert into mycodes values (cd);
end for;
end@

set delimiter = ;
--------
-------
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On