Define and Verify a Post-Build Event that Binds the Application

Walks you through the process of defining a post-build event that automatically binds the application after building the project.

Define a post-build event

  1. In the Properties window, click the COBOL tab; then click Build Events.
  2. In the Post build event command line field, type the following command:
    DSN SYSTEM(HCODemo) @"$(ProjectDir)LBLDURATION.hcodsn"

    This command calls the DSN Bind utility, specifies the SQL database connection to use, and states the location and name of a bind script file. Visual Studio executes this event immediately after building the application, automatically binding the application at that time.

  3. Click OK to close the Build Events dialog box.
  4. Close the Properties window.

View the contents of the bind script file

  • From the Solution Explorer, open and review the contents of LBLDURATION.hcodsn. This bind script file contains one BIND PLAN command that binds the LBLDURATION member into a plan named LBLDURATION.

Build and bind the applcation

  1. From the Solution Explorer, rebuild the LBLDURATION project, thereby generating a DBRM for the application and automatically binding it to the DBRM using the post-build event.
  2. Verify that the project built successfully.

Verify the results

  1. Using Microsoft SQL Server Management Studio, connect to your SQL Server instance.
  2. On the Object Explorer, expand Databases > HCO_Test > Programmability > Stored Procedures to see the stored procedures HCOSS created when you executed your packages and plan.
  3. Open the stored procedure named PLN:LBLDURATION.LBLDURATIONconsistency-token$0, where consistency-token is the value of the generated consistency token.

    In this, you see the SQL from your application code. You also see that HCOSS has converted the original DB2 DAYS expression into T-SQL syntax that recreates the same functionality in SQL Server. This is due to having set the SQL(DIALECT=MAINFRAME) directive when you compiled.