Results 1 to 3 of 3
  1. #1
    Join Date
    May 2006
    Posts
    6

    Red face Unanswered: 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?

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    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.

  3. #3
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •