Creating database objects
Before you can start developing the orchestration, you must create some sample objects to use in the database. They will be required in Studio during development. They will also contain some sample data to use for testing.
It is typical to create a dedicated user account for Cast Iron on each endpoint system it will connect to for audit purposes. DB2 uses the operating system to authenticate, so you must create a new Windows user:
- Create a test Windows user called "castiron" by selecting
Start > Control Panel > Administrative Tools
> Computer Management. Expand Local
Users and Groups, then right-click
Users > New User, as shown in Figure 1.
Figure 1. Create a new user
- Enter the user name, password, and password confirmation. Uncheck
the "User must change password at next logon" box and click the
Create button, as shown in Figure 2.
Figure 2. New user configuration
A database is required to contain the stored procedure as well as some sample data for testing.
- Launch the DB2 Control Center from the Windows
Start Menu. Create a test database called "CASTIRON" by
right-clicking on All Databases > Create Database >
Standard, as shown in Figure 3.
Figure 3. Create a standard database
- Enter the database name as
castiron, as shown in Figure 4, then click Finish.
Figure 4. Specify a database name
- Wait for the database to be created, then grant connect and create
table privileges to the user, castiron, by right-clicking the
database CASTIRON > Authorities, as shown in
Figure 5. Database CASTIRON authorities
- Click the Add User button, select
CASTIRON > OK, and then select
CASTIRON. Set CONNECT to Yes
and CREATETAB to Yes, as shown in Figure 6.
Figure 6. Grant authorities to user CASTIRON
A stored procedure is required to return the results of an SQL select statement. A table and some test data are also required for the SQL select statement to query.
The sample script provided with this tutorial completes the following tasks:
- Connects to the database CASTIRON as user "CASTIRON" and prompts the user for a password.
- Creates a table called CAST_IRON_FORM_FACTORS with three columns: ID, NAME and CREATE_DATE.
- Inserts three rows of test data into the new table.
- Creates a stored procedure called GET_CAST_IRON_FORM_FACTORS that returns the contents of the new table ordered by ID.
Run the script using the following steps:
- Open the Windows command prompt.
- Navigate to the directory containing the sample script using the
- Run the command
db2cmdto open the DB2 command window.
- Run the command
db2 -td@ -vf sample.sqlin the DB2 command window to run the sample script.