Creating DB2 Stored Procedure from the command line

In order to create a DB2 stored procedures from the command line, all what you need to do is:
1. Place "@" at the end of your "CREATE PROCEDURE" script as follows:

CREATE PROCEDURE myScheme.myProcedure
(
IN someParameter BIGINT
)
LANGUAGE SQL 
BEGIN
-- Some SQL statements

END@

2. Let’s assume that the script file name which contains the stored procedure sql is "someScript.sql", In order to execute the DB2 stored procedure creation script, run the following command from the command line:

db2 -td@ -svf someScript.sql

After running the command, you should see the success message as follows:

"DB20000I  The SQL command completed successfully.
This entry was posted in Database and tagged , , , , , , by Hazem Saleh. Bookmark the permalink.

About Hazem Saleh

Hazem Saleh has more than eleven years of experience in Cloud, Mobile and Open Source technologies. He worked as a software engineer, technical leader, application architect, and technical consultant for many clients around the world. He is an Apache PMC (Project Management Committee) member and a person who spent many years of his life writing open source software. Beside being the author of the "JavaScript Unit Testing" book, "JavaScript Mobile Application Development" book, "Pro JSF and HTML5" book and the co-author of the "Definitive guide to Apache MyFaces" book, Hazem is also an author of many technical articles, a developerWorks contributing author and a technical speaker in both local and international conferences such as ApacheCon North America, Geecon, JavaLand, JSFDays, CON-FESS Vienna and JavaOne. Hazem is an XIBMer, he worked in IBM for ten years. Now, He is working for Nickelodeon New York as a Mobile Architect. He is also an OpenGroup Master Certified Specialist.