Now that the SQL query has been generated, we can use OpenESQL Assistant to generate a generic COBOL program and embed the query right into it. 
    
 
     
       
        - Requirements 
        
 
 
        - Before attempting this tutorial, you must complete the following tutorials in the order listed: 
          
 
            - Tutorial: Create a SQL Server Database 
            
 
 
            - Tutorial: Create and Configure a Visual Studio Project 
            
 
 
            - Tutorial: Set OpenESQL Assistant Configuration Options 
            
 
 
            - Tutorial: Catalog a Connection 
            
 
 
            - Tutorial: Build and Test a Query 
            
 
 
          
 
         
 
       
       
        - Phase 1: Generate a Generic SQL Program 
        
 
 
        -  
          
 
            - Click the 
              Auxiliary Code tab. 
            
 
 
            - From the drop-down list, click 
              Generic SQL Program. 
              
OpenESQL Assistant generates a generic SQL program in the right-hand pane of the 
                Auxiliary Code tab. 
              
 
             
 
          
 
         
 
       
       
        - Phase 2: Open Program1.cbl 
        
 
 
        - In this phase, we open the program that was automatically generated when we created the 
          OESQLAssistantTutorial project, and delete its contents so we can replace them with the code generated by OpenESQL Assistant. 
          
 
            - In Solution Explorer, double-click 
              Program1.cbl. 
              
This opens the source code editor with the cursor placed at the very beginning of the file. 
              
 
             
 
            - Select and delete all text in the file. 
            
 
 
          
 
         
 
       
       
        - Phase 3: Embed the Generic SQL Program 
        
 
 
        - We're now ready to embed our generic SQL program into the 
          Program1.cbl file. 
          
 
            - Place your cursor at the beginning of the 
              Program1.cbl file. 
            
 
 
            - From the OpenESQL Assistant 
              Auxiliary Code tab, click 
              Insert Query Into Current Program 
              
. 
              The generated code appears in 
                Program1.cbl. 
              
 
             
 
            - Save 
              Program1.cbl. 
            
 
 
          
 
         
 
       
       
        - Phase 4: Embed the SQL Query 
        
 
 
        - Next, we embed our SQL query into the generic program. 
          
 
            - In the program editor for 
              Program1.cbl, place the cursor on the line just after the comment: 
              
*> Put your program logic/SQL statements here
 
             
 
            - On the OpenESQL Assistant, click the 
              Query tab; then click 
              Insert Query Into Current Program 
              
. 
              OpenESQL Assistant inserts the query into the program. 
              
 
             
 
          
 
         
 
       
    
 
    This completes the tutorial. Next, please complete 
      Tutorial: Provide Additional Code.