Walks you through the process of using the OpenESQL Assistant to code a SQL Server COBOL stored procedure that looks up an
employee number and returns the employee number and first and last names of the employee.
Set OpenESQL Assistant Options
By default, the OpenESQL Assistant generates TSQL stored procedures. You need it to generate SQL CLR stored procedures.
- From the
VisualStudio IDE, click
Tools > Options; then expand
Micro Focus Tools and click
OpenESQL Assistant.
- On the option list in the
Query group, use the drop-down list to set
Type Stored Procedure to
SQL CLR, and then click
OK.
Create a SQL CLR Stored Procedure Query
As you construct the query, the OpenESQL Assistant generates all code necessary to complete the stored procedure program,
including host variables and SQLCA declarations.
- In the
OpenESQL Assistant, check the
EMP (TEST) table listed under the
SQLServerDB connection entry.
- On the
Select Type of Query to Create dialog box, click
SELECT (Singleton).
- Check
Generate Query as a SQLCLR Stored Procedure.
- In the
SP name field, type
LookupEMP. The
OpenESQL Assistant uses this name for both the generated program and the stored procedure.
- Click
OK.
- On the tree view, check the
A.EMPNO,
A.FIRSTNME, and
A.LASTNAME columns to add them to the query.
- In the right pane, click the
Search Criteria tab.
- Verify that the following fields are set to the values specified:
Column
|
A.EMPNO
|
Conditional Operator
|
=
|
Target Type
|
Host Variable
|
Target Value
|
:EMP-EMPNO
|
- Click
> (right arrow) to construct the arguments for the WHERE clause of the SELECT statement you are constructing.
Add the stored procedure to the SQLServerSP project
- In the Visual Studio
Solution Explorer, click the
SQLServerSP COBOL project name to select it.
- In the
OpenESQL Assistant, position the mouse pointer over the toolbar; then right click and select
Add SP to SQLCLR project.
The
OpenESQL Assistant adds the stored procedure to the project in the file
SQLServerSP.cbl.
- Close the
OpenESQL Assistant.
Delete the StoredProcedure1.cbl file
The program that was generated by default when you created the project,
StoredProcedure1.cbl, is no longer required. Now is a good time to delete it.
- In the
Solution Explorer, right-click the
StoredProcedure1.cbl file and select
Delete.
- Click
OK to confirm deletion.
- Click
Save All
.