[Migrated content. Thread originally posted on 25 May 2012]
Hello,
I am running Microfocus NetExpress COBOL program on LINUX in a batch mode. I execute a SQL query fronm the COBOL program. What I would like is when my query ends up in error, I would like to log an error in a log file, with the query that has just run. Is there a runtime variable that exists where the last executed query is stored? It would make my life easier cause I would then be able to log exactly the correct query without having to "restring" it in my COBOL program.
I use an Oracle database.
Thanks,
Sophie
If you are running the program under Linux then it must be Server Express that you are using as Net Express is a Windows only product.
You state that you use Oracle but do not say whether it is Pro*COBOL or OpenESQL (ODBC) that you are using to do the precompiling.
Regardless, I do not believe that what you are looking for is actually possible as the statements that you execute at the source level are not the actual statements that are being executed at run-time.
These statements are run through a preprocessor which generates the actual calls to the Oracle libraries or to the ODBC API. One EXEC SQL statement usually generates many actual calls to the database run-time including calls for error handling etc.
If you generate a trace file you can see the actual statements that are being executed.
To the best of my knowledge, there is no routine that can be called or environment variable that can be queried that would contain this information. If there is a way, perhaps one of our database developers can enlighten us here.
Thanks.