forum.vmspython.org Forum Index forum.vmspython.org
Forum system
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Calling SQL Database from OpenVMS Cobol
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forum.vmspython.org Forum Index -> MySQL for OpenVMS
View previous topic :: View next topic  
Author Message
hornjt



Joined: 03 Apr 2007
Posts: 1

PostPosted: Tue Apr 03, 2007 10:30 pm    Post subject: Calling SQL Database from OpenVMS Cobol Reply with quote

Is there a way for OpenVMS Cobol with MySQL installed to make a call to a remote call to a SQL database?
Back to top
View user's profile Send private message
jfp



Joined: 12 Jul 2004
Posts: 625

PostPosted: Wed Apr 04, 2007 9:59 pm    Post subject: Reply with quote

MySQL use a API written in C, so you will have to call the C routines from your Cobol program, may be it is easier to write some jacket routine.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dgrenier



Joined: 19 Dec 2007
Posts: 8
Location: Alberta, Canada

PostPosted: Wed Dec 19, 2007 10:18 pm    Post subject: OpenVMS Cobol with MySQL Reply with quote

Are there any examples or documentation available on what is required with calls to the C routines?

I'm must getting started on a project to mirror/convert the data in our RMS data files to MySQL and ideally would like to be able to update both systems when a user makes a change. Our current system is written in Cobol.

Thanks for any advice.
Back to top
View user's profile Send private message
jfp



Joined: 12 Jul 2004
Posts: 625

PostPosted: Thu Dec 20, 2007 7:52 am    Post subject: Reply with quote

Quote:
Are there any examples or documentation available on what is required with calls to the C routines?


If you want to know how to use the C MySQL API there are lot of documentations, online, books, and I can post few examples or give you some pointers.

I you want to know how to call the C API from COBOL, you will have to find the correct mapping of argument between COBOL and C. May be a COBOL/C expert can help, in this case I suggest you try the HP ITRC forum, you will probably find more help.

JF
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dgrenier



Joined: 19 Dec 2007
Posts: 8
Location: Alberta, Canada

PostPosted: Thu Dec 20, 2007 5:10 pm    Post subject: Reply with quote

Thanks for the reply JF.

I had a quick look online and on the MySQL site yesterday to see what I could find but so far nothing too helpful. If you have a minute to post a couple of examples to give me a kick start it would be greatly appreciated. (Or if you can point to an appropriate online source?).

Finding time for research is currently a bit of a problem for me. Once I get started I think I can figure out calling C API's from COBOL. IF not, I will try the HP ITRC forum as you suggest.

Many thanks,

Dale
Back to top
View user's profile Send private message
bisonmalembouche



Joined: 01 Jun 2005
Posts: 74

PostPosted: Thu Dec 20, 2007 5:56 pm    Post subject: The Cobol manual Reply with quote

In the Cobol doc, you have

Example 12-17 C Routine to Be Called from a COBOL Program
at
http://h71000.www7.hp.com/doc/82final/6297/6297pro_094.html

and the other way

Example 12-8 Calling a COBOL Program from C (Alpha, I64)
http://h71000.www7.hp.com/doc/82final/6297/6297pro_092.html#other_lang_sec

Regards
Back to top
View user's profile Send private message Send e-mail
dgrenier



Joined: 19 Dec 2007
Posts: 8
Location: Alberta, Canada

PostPosted: Thu Dec 20, 2007 10:48 pm    Post subject: Reply with quote

Thanks for the information so far, forgive me, I'm a newbie to MySQL.

I've determined that I have first to find where/how I can access the mysqld library, etc on our OpenVMS system before I can begin to worry about how to use the C API's. I did read somewhere that you have to build MySQL on the system rather than just do an install before these will be available? Is this true? I have downloaded the source in anticipation that I will need to do the build but haven't gotten as far as figuring out all the steps required to do the build (I do see a make_all.com file...).

Thanks again,

Dale
Back to top
View user's profile Send private message
jfp



Joined: 12 Jul 2004
Posts: 625

PostPosted: Sat Dec 22, 2007 5:37 pm    Post subject: Reply with quote

You don't need to build MySQL from source, just download the kit (4.1 or 5.1) and install it.

You can take a look at the wiki http://vmsmysql.dyndns.org/

I don't know who is the guy who have said that you have to rebuilt from source but it's definitively wrong.

JF
Back to top
View user's profile Send private message Send e-mail Visit poster's website
david



Joined: 14 Dec 2007
Posts: 8

PostPosted: Thu Jan 03, 2008 4:20 pm    Post subject: Reply with quote

Is there any reason a runtime library could not be built ?
It could expose the mysqlclient functions in a Cobol friendly way.

I've built one that does the "simple" functions, connect, disconnect, select, etc... seems to work ok, but it doesn't expose all API functions.
Back to top
View user's profile Send private message
jfp



Joined: 12 Jul 2004
Posts: 625

PostPosted: Sun Jan 06, 2008 12:09 am    Post subject: Reply with quote

david wrote:
Is there any reason a runtime library could not be built ?
It could expose the mysqlclient functions in a Cobol friendly way.

I've built one that does the "simple" functions, connect, disconnect, select, etc... seems to work ok, but it doesn't expose all API functions.


What do you call a "runtime library"?

JF
Back to top
View user's profile Send private message Send e-mail Visit poster's website
david



Joined: 14 Dec 2007
Posts: 8

PostPosted: Mon Jan 07, 2008 5:15 pm    Post subject: Reply with quote

good question.

Some call it run time library, I've also heard it called a "shared image".

The point is, logic is encapsulated in an ".EXE" file.
When the .EXE is linked, you specify the entry points that you want to
expose to the "callers".

A consumer (caller of one of these entry points) would just "link against"
the .EXE and NOT against the mysql client object library.

the run time library can now be changed, enhanced, bugFixed etc. then re-linked without having to re-link all callers... by taking care NOT to change the order of the entry points

There are of course image PSECT attribute requiements that must be satisfied before the run time library can be "shared" to multiple callers .

What I've built:

1 - CobolProgram.exe
This exe is linked against mysqlshr.exe.

2 - mysqlShr.exe ( my run time library)
The functions exposed are Cobol friendly.
This exe is linked pulling from mysql client object library those
objects to satisfy the functions I expose ( connect, disconnect, query,
etc)

My goal is for mysqlshr to "export" a subset of the mysql c-api that would satisfy 80-90% of the typical program data access requirements.

What I don't know is if any of the objects that I might pull from the mysql client object library might break the "share-ing" requirements of a run time library. I am scanning the image map for psects that are marked
"SHR" and "WRT". So far I haven't encountered any.

Hope this helps.

david
Back to top
View user's profile Send private message
jfp



Joined: 12 Jul 2004
Posts: 625

PostPosted: Mon Jan 07, 2008 5:40 pm    Post subject: Reply with quote

Ok, I understand.

Initial port of MySQL include a client shareable image, it is easy to build such shareable. But the problem which will become rapidly a nightmare is to maintain a compatible shareable.

MySQL change, very often, the API without any compatibility respect.
So I have decide to not provide a shareable, which would be easier than to provide the 2 .olb libraries because an shareable can export upper case and mixed case symbol. But as it is difficult to maintain compatibility between each version I have remove this option.

Provide a shareable which is not compatible with the previous one is, IMHO, worse than not provide it.

But if someone want to build a shareable which contains all the API and maintains it would be more than welcome Very Happy

JF
Back to top
View user's profile Send private message Send e-mail Visit poster's website
cw



Joined: 08 Feb 2008
Posts: 6

PostPosted: Mon Feb 11, 2008 7:04 pm    Post subject: Reply with quote

jfp wrote:
MySQL use a API written in C, so you will have to call the C routines from your Cobol program, may be it is easier to write some jacket routine.


Can I just ask a quick clarification question. Do you mean that you have to write C code to call the APL and then call the C code from Cobol?


regards,

Chris
Back to top
View user's profile Send private message
jfp



Joined: 12 Jul 2004
Posts: 625

PostPosted: Mon Feb 11, 2008 7:43 pm    Post subject: Reply with quote

cw wrote:
Do you mean that you have to write C code to call the APL and then call the C code from Cobol?


I think that you do not have to, you may have to.

You may find that it's easier for some MySQL routines to write C routines which do most of the job, then just call these routine from your Cobol program, probably not mandatory.

But I haven't try to write any Cobol program accessing MySQL.

JF
Back to top
View user's profile Send private message Send e-mail Visit poster's website
rft



Joined: 20 Jun 2007
Posts: 43
Location: Massachusetts

PostPosted: Thu Feb 14, 2008 10:03 pm    Post subject: Reply with quote

We have written a FORTRAN callable interface to allow access to MYSQL. It consists of a small C routine that provides the minimum functions:

Init - initialize for MYSQL access
Close - close connection
Query - pass query to MYSQL
Fetch_Row
Fetch_Field
Num_Fields
Field_Lengths
Free_Result

The above are basically jacket routines that expose the underlying C calls in the MYSQL API.

We then wrote FORTRAN functions that call the C routines emulating the functions that we use to access our RMS ISAM databases.

There is a small C example program found at:

http://www.ucl.ac.uk/is/mysql/c/

that shows most of what is needed to access MYSQL through C.

Please remember that most of the power of MYSQL is in the query language through which most any desired operation can be performed.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vmspython.org Forum Index -> MySQL for OpenVMS All times are GMT + 2 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group