On 30.05.25 21:14, David Clark wrote:
> This is my first time using the Squirrel SQL Client (v8.4). I'm trying
> to create a DB2 stored procedure and getting the following error
> message. I'm not completely sure what it is trying to tell me. I know
> that the state indicates a syntax error, and I'm guessing that the
> SQLERRMC indicates the failing statement. Does the string after that
> indicate the previous characters in my source? ...leading up to that
> statement? And why does it say "TRUNCATE"? I know the ALTER statement
> is good, though; because I can execute it by itself elsewhere. So, I'm
> confused. Help?!?
>
> Error: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=ALTER;OP'
> Then Begin
> ;TRUNCATE, DRIVER=4.33.31
>
As SQuirreL's default statement separator is ; (semicolon) and DB2 uses
; as an internal separator you might first want to adjust SQuirreL's
statement separator at menu File --> New Session Properties --> tab SQL
--> section "Statement" separator.
As stored procedures often contain empty lines, make sure the complete
procedure is selected in SQUirreL's editor before you click the run
button or hit Ctrl+Enter.
Below you find an example of a stored procedure that I could create and
execute from within SQuirreL.
To call the procedure from within SQuirreL you must use the JDBC format
{call READ_MYTABLE(42)}
although I noticed that for me
call READ_MYTABLE(42)
works as well.
Gerd
-- Example Stored Procedure for DB2/LINUXX8664 version SQL110550
--
CREATE OR REPLACE PROCEDURE READ_MYTABLE(IN MYTABLEIDVAR INTEGER)
LANGUAGE SQL
DYNAMIC RESULT SETS 1
BEGIN
DECLARE cursor1 CURSOR WITH RETURN TO CALLER
FOR (SELECT * FROM MYTABLE WHERE MYTABLEID = MYTABLEIDVAR);
OPEN cursor1;
END
|