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 > Problem when using Begin Atomic/ End to write Function.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-21-03, 16:13
Xun_Zhang Xun_Zhang is offline
Registered User
 
Join Date: Nov 2003
Posts: 16
Problem when using Begin Atomic/ End to write Function.

I have created Function f1 and Function f2. f1 is a single-statement one while f2 has a multiple lines.
--f1
CREATE FUNCTION f1()
RETURNS VARCHAR(2)
SPECIFIC f1
RETURN 'ok';

--f2
CREATE FUNCTION f1()
RETURNS VARCHAR(2)
SPECIFIC f2
BEGIN ATOMIC
DECLARE v VARCHAR(2);
set v = 'ok';
RETURN v;
END;

when i run
db2 -tf filename
to add those functions,

adding f1 is ok. but for f2, I always receive an error with error code 42601 saying unexpected character ")" after "DECLARE v VARCHAR(2",
I am using DB2 8.1.4 FixPack4 on windows platform.

Anyone has some idea about that problem?
Thanks.
Reply With Quote
  #2 (permalink)  
Old 11-21-03, 17:40
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Re: Problem when using Begin Atomic/ End to write Function.

CREATE FUNCTION f1()
RETURNS VARCHAR(2)
SPECIFIC f1
RETURN 'ok' @

--f2
CREATE FUNCTION f1()
RETURNS VARCHAR(2)
SPECIFIC f2
BEGIN ATOMIC
DECLARE v VARCHAR(2);
set v = 'ok';
RETURN v;
END @

db2 -td@ -f filename

Cheers

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 11-21-03, 17:48
Xun_Zhang Xun_Zhang is offline
Registered User
 
Join Date: Nov 2003
Posts: 16
UNDERSTOOD.

Thanks a lot.
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