How to connect DB2 using Micro Focus Extension on VS Code?

I am using VS Code to code Visual COBOL. And one of my programs will require to connect to DB2 (MySQL Workbench).

As per my research, I need to have ODBC to apply the OpenESQL in microfocus. But as I was trying to compile my cobol program, I am hitting an error saying:

error COBCH0149 : No SQL directives have been set.

But on the upper part i have declared $SET SQL. 

I also tried updating the default directives to include sql, i am still getting COBCH0149 error.

  • 0   in reply to 

    Is Visual COBOL installed in the default folder, c:\program files (x86)\micro focus\visual cobol and is your VSCode extension setting "Install location" set to that?

    Is your PATH perhaps pointing to a folder with an older product, like Net Express in it?

    Try adding the SQL directive to the .bat file.

    cobol VSCodeDB.cbl/sql(dbman=odbc) int() anim;

    Chris Glazier
    Rocket Software - Principal Technical Support Specialist
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button

  • 0 in reply to   
    c:\program files (x86)\micro focus\visual cobol

    For this one, I dont see this on my machine. We go directly installing the extension micro focus cobol.

    After installing the extension, it generates a folder "Community Edition" folder. Havent touch this folder since the installation of the extension.

    Try adding the SQL directive to the .bat file.

    cobol VSCodeDB.cbl/sql(dbman=odbc) int() anim;

    It says invalid qualifier -sql(dbman=odbc)

  • 0   in reply to 

    ah, you are using the Community Edition of the Visual COBOL product. I have been testing with a full version of Visual COBOL for Visual Studio 2022.

    I will set up an environment and test this here.

    Chris Glazier
    Rocket Software - Principal Technical Support Specialist
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button

  • Verified Answer

    +1   in reply to 

    I just confirmed that there is no support for the OpenESQL preprocessor in the Visual COBOL Community Edition product which is installed with the Learn COBOL extension in VSCode. This edition of Visual COBOL is mainly for use with the Learn COBOL course and database access is not covered in this course.

    If you want to have the full functionality available in Visual COBOL, including database support, then you have to install a full version of the Visual COBOL product and point VSCode to its install folder. 

    I would recommend that you download a copy of Visual COBOL Personal Edition from our web site here. It is a free full product version which is licensed for one year. 

    Thanks.

    Chris Glazier
    Rocket Software - Principal Technical Support Specialist
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button

  • 0 in reply to   

    I see. Thank you Chris.