Re: Embedded SQL, PL/SQL in Cobol



Jeff,

Here is a very basic sample that will connect to an Oracle database.
You can always expand the EVALUATE statement to include other various
SQLCODEs so that you can incorporate your own error messages if
desired. Also, you'll need to run this with the Oracle run-time
(rtsora) or build a shared library that you make an initial call to in
order to load the Oracle functions.

Good luck.

Chris



identification division.
program-id. dbconnect.

data division.

working-storage section.

exec sql include sqlca end-exec.

exec sql declare dbname database end-exec.

exec sql begin declare section end-exec.

01 db-user pic x(10).
01 db-passwd pic x(10).

exec sql end declare section end-exec.

procedure division.

move "myLogin" to db-user
move "myPassword" to db-password

exec sql
connect
:db-user
identified by
:db-passwd
at
dbname
end-exec

evaluate sqlcode
when 0
display "You are connected!" end-display
when other
display "Error: " sqlerrmc(1:sqlerrml - 1)
end-display
end-evaluate

goback returning 0
.

.



Relevant Pages