Working with the Getting Started application – Basic
First run the precompiler:
citoesql sample.cbl
- The -g parameter is required if you want to compile for debugging. You can omit it from release builds.
- The -conf=citoesql.conf parameter sets compiler options required by CitOESQL including running CitOESQL’s preprocessor and linking its runtime library.
- You can also run CitOESQL as a standalone preprocessor and then compile the generated output file.
Next compile the file generated by CitOESQL, which will have the same name but a .cbp extension.
- Windows: cobc -g -l%COBOLITDIR%\lib\ citoesqlr_dll.lib sample.cbp
- Linux: cobc -g -L\$COBOLITDIR/lib -lcitoesqlr sample.cbp
Note
The -I parameter links CitOESQL’s runtime library.
The application can now be executed using cobcrun
. Enter the DSN, User-ID and Password when prompted. The console output should be as follows:
cobcrun sample
Create/insert/update/drop test
Enter data source (Eg odbcdemo) MyDSN
Enter username[('.'\|'/')password] (Eg admin/) myUserId.myPassword
Drop table
Error(anticipated) : cannot drop table
-00003701
Cannot drop the table 'mfesqltest', because it does not exist
Create table
Insert row
Commit
Update row
Verify data before rollback
Rollback
Verify data after rollback
Drop table
Disconnect
Create table after commit release
Cannot create table as expected
-00019702
Connection name not found.
Test completed without error
You can debug the application using cobcdb, as detailed in the Using the COBOL-IT Debugger section of the COBOL-IT Compiler Suite, Getting Started With Compiler Suite guide.
To build an executable program rather than the default dll or shared object add -x to the command line as shown in the example below:
cobc -x -g -conf=citoesql.conf sample.cbl
Working with the Getting Started application in Developer Studio
Prerequisites
Set up a new workspace by following the steps documented in the Developer Studio Getting Started manual. In summary:
-
Validate the COBOL-IT license using the menu sequence Window > Preferences > COBOL then click the Browse button to select the COBOL-IT license file.
-
Using the menu sequence Window > Preferences > General > Editors > Text Editor, ensure Show line numbers has been checked.
-
Using the menu sequence Window > Preferences > General > Workspace:
- De-select Build automatically
- Select Refresh using native hooks or polling
- Select Refresh on access
- Select Save automatically before build
-
Using the menu sequence Window > Preferences > Run/Debug > Perspectives, select Always for the Open the associated perspective when launching.
Project creation and import of source code
Follow the steps listed to create a new project and import source code.
-
Select File > New > COBOL Project… to open the COBOL Project Wizard.
-
Enter a project name, for example samples, and click Finish.
-
Right click on the newly created project and select New > Folder, enter the name object and click Finish.
-
Right click on the project again and select Import followed by General and FileSystem then click Next.
-
Click Browse and navigate to the COBOL-IT samples > sql directory, then click OK. Select sample.cbl and click Finish.
-
Right click on the project again and select Properties followed by COBOL Properties then check the Enable source settings option.
-
Select DevOps Tools > Debugging Tools. Check Enable source settings and Produce debugging metadata in compiled object.
-
Select Dialects > Compiler Configuration Files. Enter citoesql.conf for Use
<file>
as configuration file. -
Select Link > Full Build and set Build type to Build executable program.
-
Select Standard Options and check Save object file in source folder or in
<directory>
and enterobject
in the textbox. -
Click Apply and Close.
Build and Debugging
To build the project use the menu sequence Project > Clean, ensure the project is selected for cleaning and building and then click Clean.
You now need to set up a debug configuration as follows:
-
Double click on sample.cbl to open the source file.
-
Scroll down to the EXEC SQL CONNECT statement, right click the shaded area to the left of the line number of the EXEC SQL line and choose Toggle Breakpoint. A blue circle should appear next to the line number. You can also use double click to set and unset breakpoints as an alternative to right click.
-
Right click on sample.cbl in the project file tree in the left-hand pane, select Debug As followed by Debug Configurations.
-
Click on Cobol Program followed by the left most icon in the toolbar above (New launch configuration) and enter ‘sample’ as the configuration name at the top of the dialog box.
-
Check that the Project Name is set to the correct project and that Program is set to sample.cbl.
-
Click Debug.
-
Respond to the prompts from the program with the ODBC Data Source Name, User-ID and Password.
-
The application will stop on the breakpoint. You can now use other debugger features to inspect COBOL variables, manage other breakpoints, use single step code execution, etc. Please consult COBOL-IT Developer Studio, Getting Started: The Debugger Perspectiveguide for more information.