Search code examples
stored-proceduresdb2razorsql

DB2 stored procedure razor sql


I'm trying to create a stored procedure in a DB2 database using RazorSQL Client but I'm getting this error:

Blockquote ERROR: A character, token, or clause is invalid or missing. DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=SELECT

The stored procedure code is:

CREATE PROCEDURE GENERAL.sp_checkemp
(IN emp_code VARCHAR(20))
LANGUAGE SQL
READS SQL DATA


BEGIN

    SELECT "name_emp" FROM GENERAL."employee" WHERE "code_emp" = 'abc';

END

Solution

  • SELECT statements in the SQL PL context must have an INTO clause -- you have to put the query results somewhere. If your query returns more than one row, which I suspect it is, you must use a cursor instead.