Operating System - HP-UX
1748148 Members
3905 Online
108758 Solutions
New Discussion юеВ

Re: How to access Oracle database via Cobol

 
SOLVED
Go to solution
Andre Machado_1
Advisor

How to access Oracle database via Cobol

Hi body,

I need access a Oracle Database from a Cobol program, but I don?t kown.

I?d like a little sample.

Thank you!
11 REPLIES 11
Thierry Poels_1
Honored Contributor

Re: How to access Oracle database via Cobol

Hi Andre,
Pro*Cobol is the thing you need. This will allow to incorporate SQL-statements in your Cobol programs. (Requires an Oracle license however)
sorry no (Pro*)Cobol examples from me
good luck,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
A. Clay Stephenson
Acclaimed Contributor

Re: How to access Oracle database via Cobol

AS Thierry says, Pro*COBOL is what you need. I've attached a sample of code that will give you an idea of what is involved. I'm not really a COBOL guy myself (C, C++) but I have done some work on replacing all the existing I/O with SQL and it works well. You can still retain conventional I/O as well. When you purchase PRO*COBOL you also get PRO/C.
If it ain't broke, I can fix that.
Tim Medford
Valued Contributor

Re: How to access Oracle database via Cobol

Hi Andre.

Can you be more specific about what you're trying to do. What OS is Oracle running on? Where are the Cobol programs running? On the same platform?

If you have Oracle running on HPUX, and some old mainframe COBOL programs running on an IBM mainframe, you're going to need a lot more than Pro*COBOL to access Oracle. You will need and Oracle gateway product (Procedural or transparent gateway for example). This is a major architectural change I'm talking about.

We have some Legacy COBOL code that needs to access Oracle too. As much as I hate data replication, we opted to write an interface which loads the Oracle data into a DB2 database on the mainframe. The COBOL programs then access the data in DB2 on their native platform.

Regards,
Tim
Andre Machado_1
Advisor

Re: How to access Oracle database via Cobol

Hi Tim,

I have a L1000 Machine and MicroFocus Cobol 13.35 on HP-UX 11.00, and oracle 8 on some machine. I haven?t ODBC.

I need access a Oracle databse to verify the client table.

Thank you for your help!
A. Clay Stephenson
Acclaimed Contributor

Re: How to access Oracle database via Cobol

Given that Pro*COBOL will work just fine on either a local machine or a remote database instance. If you are trying to connect to a remote oracle instance you don't need ODBC but you do need to oracle client software installed on the local machine and a listener configured on the remote machine. I would start out do very simple tasks and build on them. This is not difficult. I started out barely being to spell COBOL but nevertheless could connect and do oracle I/O very quickly. I was comfortable using SQL and doing the same task in C before I did any COBOL.
If it ain't broke, I can fix that.
Andre Machado_1
Advisor

Re: How to access Oracle database via Cobol

I will access oracle from local host.

What I need?
Joseph C. Denman
Honored Contributor

Re: How to access Oracle database via Cobol

1. telnet to the machine with the oracle account
2. export ORACLE_SID=yoursid
3. sqlplus user/passwd
4. select whatever from table
5. exit

Hope this helps

...jcd...
If I had only read the instructions first??
A. Clay Stephenson
Acclaimed Contributor

Re: How to access Oracle database via Cobol

If you are running on the local host. Sqlplus should already be installed. I can think of two ways to do this. 1) Install Pro*COBOL and examine the attached sample I've already sent or 2) if the SQL commands are simple you can build SQL statements within COBOL and write the to a text file 'on the fly' and then EXECUTE an external program (sqlplus) to read and process the SQL statements. Method 2 works but you will have to do a lot of text processing of the results withinn your COBOL program.
I would get the Pro*COBOL compiler; it is much easier and is a marketable skill.
If it ain't broke, I can fix that.
Andre Machado_1
Advisor

Re: How to access Oracle database via Cobol

Where I get PRO Cobol?