简体   繁体   中英

SQLCode -991 when trying to read from DB2 table

I've created and compiled a program in Cobol, but when trying to run and test it with a JCL job, I'm getting this error when reading the output. (The program compiles and the job runs without errors themselves)

SQLCODE = -991, ERROR: CALL ATTACH WAS UNABLE TO ESTABLISH AN IMPLICIT CONNECT OR OPEN TO DB2. RC1=0008 RC2=00F30034

SQLSTATE = 57015

Now I don't understand why this error occurs. The DB2 database is up and running, I can access it myself. I can't find an error in my program code either. Googling it sadly doesn't provide me a clear solution, all I can find is that the issue is either the compiling job for the program, the jcl to run it or issues with the DB2 itself.

Have you done a bind and did it work !!!, The error indicates the plan does not exist or is not authorized .
You need to talk to people at your site about the Compile/Bind process and who authorises

If you do not know know about Mainframe Cobol/DB2 compile process, try reading this

Basically --->

                                 Cobol program 
    Cobol DB2 Program ---+---->  with no  SQL   ---> Compile ----->  Executable
                         |       but calls Plan  
                         |
                         +---->  DBRM (SQL)   -----> Bind   ------>  DB2 Plan    

It is the plan that needs the DB2 authorisation to run the SQL !!! You might be able to authorise the Plan or you might need to see the DBA's

With DB2 COBOL, There is Co-Compiler (was a pre-compiler) that strips out the SQL and creates the DBRM (basically aa special SQL procedure).

It is the Bind that processes the DBRM (SQL) and creates DB2 access plans


This may seem long winded after java etc. But there are some advantages

  • The SQL is processed ahead of time and not while the program is running
  • You can check the DB2 access path at any time - Before / after execution. Useful for analysing performance issues.
  • The same DB2 access paths are used from one run to the next. This leads to fairly predictable run times.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM