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 > Help me with this simple procedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-02-06, 05:21
zsevgymko zsevgymko is offline
Registered User
 
Join Date: May 2006
Posts: 6
Red face Help me with this simple procedure

Hi to all, here it is :

create procedure
smart_group.sp_L_Check_For_Deletion(in nPTID integer)
reads sql data
language sql
begin
if exists(select * from smart_group.L_RequiredQuans as req join
smart_group.L_ReservedQuans as r on r.RequireID = req.id where
r.SOURCE_PTID = nPTID) then
raise_error('99999','some message here');
--signal sqlstate '99999',('some message here');
end if;
end

And here is the exception I receive :
SQL0104N An unexpected token "raise_error" was found following "_PTID = nPTID) then
". Expected tokens may include: "RETURN

I've tried switching between "raise_error" and "signal sqlstate" and I've tried different combinations of parameters in the declaration of the procedure. I have no clues what is going on. Any ideas?
Reply With Quote
  #2 (permalink)  
Old 06-02-06, 05:28
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Probably, it is your SIGNAL Statement's syntax ..

The following works for me :

create procedure
smart_group.sp_L_Check_For_Deletion(in nPTID integer)
reads sql data
language sql
begin
if exists(select * from sysibm.sysdummy1 ) then
signal sqlstate '99999' set message_TEXT='SP ERROR' ;
end if;
end
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 06-02-06, 05:45
zsevgymko zsevgymko is offline
Registered User
 
Join Date: May 2006
Posts: 6
Thanks,that works, I don't know why but I was sure the syntax of signal sqlstate is correct, probably because it works in triggers
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