Stored Procedures for IBM DB2

I am new to stored procedures. Need to pick up some stored procedures for DB2(which I am also new to). The code I wrote is not working:

CREATE PROCEDURE sp_test
(
    id NUMBER
)

BEGIN    
    IF NUMBER < 0 THEN
        RAISE VALUE ERROR;
    END IF;

    SELECT * FROM student_tb
    WHERE taskid = 'NUMBER';

END;
/

and this is the script (another file) which calls the stored procedure:

BEGIN 
    sp_test('15');
END;

I am not sure what is wrong. Hope someone can advise. Thank you.

Answers


I'm not an expert in DB2, but I'm pretty sure you have to CALL stored procs in DB2.

call sp_test('15');

or

execute (call sp_test('15'));

The syntax might be a little different for stored procedures that return a result set. Docs for DB2 on your target platform should explain the difference.


Need Your Help

Questions when customize the header of a pivotitem

silverlight windows-phone-7 xaml

try to customize the header of each PivotItem, i google first and write code below, this is OK:

Date Range Picker loses range when closed

javascript twitter-bootstrap daterangepicker

I am struggling with an issue. I want to close the date range picker when a user starts scrolling down the page. I am using this plugin to create the date range picker: