1

I am trying to connect to a database in COBOL, using the embedded SQL processor. The problem is that I can't figure out how to make the connection. The documentation for the CONNECT statement says to use datasource|servername, but what is it actually? I tried using the CONNECT WITH PROMPT, and it opens a configuration screen, but I can't make it to work. How can I make the connection using this SQL embedded processor?

I am using MicroFocus NetExpress compiler, version 5.1.6.14.

The code I am using:

$set SQL

working-storage section.
exec sql
    include sqlca
end-exec.
01 SQLCA.
    05  SQLCAID         PIC X(8)         VALUE "SQLCA   ".
    05  SQLCABC         PIC S9(9) COMP-5 VALUE 136.
    05  SQLCODE         PIC S9(9) COMP-5 VALUE 0.
    05  SQLERRM.
        49  SQLERRML    PIC S9(4) COMP-5.
        49  SQLERRMC    PIC X(70).
    05  SQLERRP         PIC X(8).
    05  SQLERRD         PIC S9(9) COMP-5 OCCURS 6 VALUE 0.
    05  SQLWARN.
        10  SQLWARN0    PIC X.
        10  SQLWARN1    PIC X.
        10  SQLWARN2    PIC X.
        10  SQLWARN3    PIC X.
        10  SQLWARN4    PIC X.
        10  SQLWARN5    PIC X.
        10  SQLWARN6    PIC X.
        10  SQLWARN7    PIC X.
        10  SQLWARN8    PIC X.
        10  SQLWARN9    PIC X.
        10  SQLWARN10   PIC X.
        10  SQLWARNA    REDEFINES SQLWARN10 PIC X .
    05  SQLSTATE    PIC X(5).

procedure division.

exec sql
     connect to ':ws-base-src' as banco user 'sa.'
end-exec

display SQLCODE

I always get the return code: 19703. From this documentation. It says that it can't make the connection.

The SQLERRM variable has this information; Data source name not found and no default driver specified.

For the CONNECT statement usage, I am following this documentation..

Rick Smith
  • 3,962
  • 6
  • 13
  • 24
Toniotti
  • 77
  • 7
  • Which database. Your problem would appear to be how to confgure the connection. This is usually external to the program. You need to look at the database documentation for how to configure the connection. – James Anderson Nov 14 '20 at 10:40

1 Answers1

0

As @James Anderson said, it was a connection configuration problem. Had to do some configuration for access on Microsoft SQL Server and the OCDB connection.

Toniotti
  • 77
  • 7