17.10.2015 Views

Getting Started with IBM Data Studio for DB2

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 8 – Developing SQL stored procedures 239<br />

chapters. See Chapter 1 to learn how to download and create the GSDB database, and<br />

Chapter 2 to learn how to connect to that database.<br />

<strong>Data</strong> <strong>Studio</strong> provides helpful templates, editors and views to productively create, deploy,<br />

run, view, edit, and debug stored procedures. The overview of the steps to develop a<br />

stored procedure in <strong>Data</strong> <strong>Studio</strong> is shown in Figure 8.2.<br />

Figure 8.2- Steps to develop a stored procedure<br />

To develop a stored procedure:<br />

1. First, create the stored procedure. With <strong>Data</strong> <strong>Studio</strong>, you can create template-based<br />

stored procedures, including the required input and output variables, and SQL<br />

statements. The stored procedure’s source code is saved in your project workspace.<br />

The stored procedure is stored in the data design project in which you created it, and<br />

you can open it from the Stored Procedures folder in the <strong>Data</strong> Project Explorer.<br />

2. Next, deploy the stored procedure. When you deploy a stored procedure, <strong>Data</strong> <strong>Studio</strong><br />

submits theCREATE PROCEDURE statement to the <strong>DB2</strong> database server, which<br />

compiles it. If it is successfully deployed on the database server, you can locate it in<br />

the database when you drill down through the structures in the <strong>Data</strong> Source Explorer.<br />

3. Next, run the stored procedure so that you can test it by providing data <strong>for</strong> input<br />

variables.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!