|
From: | Frank Polscheit |
Subject: | [open-cobol-list] SQL pre-processor for OPEN-COBOL (very early alpha version) |
Date: | Mon Feb 16 21:51:04 2004 |
Hi everybody, I have implemented
a pre-processor for embedded SQL and open-cobol, tested with the open-source
database postgresql. This is the very early alpha version, which means, that
there is currently no documentation available – just the code and a example.
It’s written in RUBY and runs well under LINUX Suse 9.0. The ruby program
scans the original COBOL source file, passed as a command line parameter to the
shell script “cobsql” and produces a modified cobol source file, marking
all embedded SQL commands as comments and call C functions instead, a cobol
copybook with additional variable definitions and a C file for “ecpg”,
which is the C-pre-processor for embedded SQL used by postgresql. All compiling
and linking will be done by the shell script including launching cobc. The following 3
environment variables have to be set before running an executalbe, produced by “cobsql”.
You have to replace “myDB” by the name of your database. Both
variables, PGSQL_USER and PGSQL_PASSWORD, can be left empty but they have to be
defined as they are used for auto-connecting to the specified database. So, you
can use shell scripting for batch programming in order to connect to the SQL
database without user input. Alternative, you can explicitly call the C
function “SQL_OPEN” using the cobol variables of the generated copybook
(watch the code: after the 3 move-statements at program start, the call has to
be added in this case). All “EXEC SQL DECLARE BEGIN SECTION” etc. to
declare the host variables are not necessary and can be left out. The ruby
programm will detect them out of the cobol original code. export PGSQL_DB=tcp:postgresql://localhost:5432/myDB export PGSQL_USER= export PGSQL_PASSWORD= Call: “./cobsql
sql.cob” to generate an executable “./sql” I would be please
for any comments and feedback. The next step is to reengineer the coding,
produce documentation and adjust bugs & features. As the generated code is
easy to read, I regard this early alpha version as not that risky to be used
... J Cheers, Frank |
cobsql.rb
Description: Binary data
sql.cob
Description: Binary data
cobsql
Description: Binary data
[Prev in Thread] | Current Thread | [Next in Thread] |