[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[open-cobol-list] Re: suggested addition to main()
From: |
Keisuke Nishida |
Subject: |
[open-cobol-list] Re: suggested addition to main() |
Date: |
Thu May 20 07:46:04 2004 |
User-agent: |
Wanderlust/2.10.0 (Venus) SEMI/1.14.3 (Ushinoya) FLIM/1.14.3 (UnebigoryĆmae) APEL/10.3 Emacs/21.3 (i386-redhat-linux-gnu) MULE/5.0 (SAKAKI) |
At Thu, 20 May 2004 09:06:48 -0400 (EDT),
David Korn wrote:
>
> It would be nice if the generation of the main() program
> contained a call to cob_enter() before invoking the top level procedure
> and to cob_exit() after returning from main(). The cob library should
> have dummy functions for these and also for cob_abort() that gets called
> when a program abends. This way, programs that use embeded
> sql could then be linked with
> -ldb2 -lcob
> with the db2 library providing its own cob_enter(), cob_exit(),
> and cob_abort() functions to connect/disconnect to/from the
> database and to provide rollback of transactions.
Why don't you write your own main function and use it?
You could write something like this:
int main()
{
cob_init(0, 0);
/* connect to db */
if (SUBR() == 0)
/* disconnect */
else
/* rollback */
return 0;
}
Then you would be able to compile your program as follows:
$ cc -c main.c
$ cobc -c SUBR.CBL
$ cobc -o a.out main.o SUBR.o -ldb2
Keisuke