How to connect from OpenEdge to MySQL database?

Posted by Valeriy Bashkatov on 27-Jan-2015 02:25

Hello,

We are looking for a solution to connect from the Progress OpenEdge database to the MySQL database.

How to do that? Through DataServer for ODBC? But in the ProKB says that the Progress DataServers are not certified or supported to connect to MySQL databases.

I tried to find some additional info or examples about this, but unfortunately did not find.

Has anyone encountered a similar task?

I would appreciate any information or practical examples.

Thank you in advance!

Regards,
Valeriy

Posted by Valeriy Bashkatov on 27-Jan-2015 09:39

For someone who would be interested in that at the future....

I found the solution (pro2mysql): www.oehive.org/.../415  

It works fine for me (OpenEdge 10.2B/Linux 32 bit).

But if someone knows another way, including an official from Progress Software, I will be happy if you will tell about it.

Thank's.

All Replies

Posted by Valeriy Bashkatov on 27-Jan-2015 09:39

For someone who would be interested in that at the future....

I found the solution (pro2mysql): www.oehive.org/.../415  

It works fine for me (OpenEdge 10.2B/Linux 32 bit).

But if someone knows another way, including an official from Progress Software, I will be happy if you will tell about it.

Thank's.

Posted by Paul Koufalis on 27-Jan-2015 10:10

Peter Judge shared an unsupported sample solution:

This page contains some code and doc which talks about calling D2C from ABL. However, the underlying tech used is vanilla ODBC and so you should be able to call almost any data source.

community.progress.com/.../2089.integrating-a-datadirect-cloud-server-into-openedge-applications.aspx

The code above always returns a new temp-table or json object, but you can update it to use a predefined temp-table.

There are some methods in the ODBCConnection class that return metadata (GetTables, GetTableSchema  and GetTypeInfo).  They are simple methods and return JSON-formatted results. The methods' comments and the output should be reasonably self-explanatory. They could use that information to create temp-tables in their ABL application.

If they choose to use this metadata to create an ABL temp-table, they can  extend the sample and add a method to use that existing temp-table to contain the query results (something like the below). Method is in ODBCConnection.cls.

   /** Executes a SQL statement and populates a result set.

       @param character A SQL statement to execute

       @param handle   A buffer handle to contains the result set */

   method public void ExecuteStatement(input pcStatement as character,

                                       input phResultSet as handle):

       CreateExecuteStatement():Execute(pcStatement, phResultSet).

   end method.

And also the method in SqlExecuteDirect to do the work

   method public void Execute(input  pcStatement as character,

                              input  phResultSet as handle):

       define variable iReturnCode as integer no-undo.

       /* 0. Set the statement id, so that we can reuse cached column schema */

       this-object:StatementId = base64-encode(md5-digest(pcStatement)).

       /* 1. execute query */

       run SQLExecDirect(input  this-object:StatementHandle,

                         input  pcStatement,

                         input  length(pcStatement),

                         output iReturnCode).

       SqlCommonLib:ProcessReturnCode(

                       iReturnCode,

                       'SQLExecDirect').

       /* 2. create schema */

       MapColumns().

       /* 3. Add data */

       LoadResultSet(phResultSet).

   end method.

Now you can call it in the below manner.

/* Execute a SQL SELECT statement and get the result set in an existing ABL temp-table */

hResultSet = buffer ttUser:handle.

cStmt = " select USERNAME, LASTNAME, EMAIL from USER ".

oD2CServer:ExecuteStatement(cStmt, input  hResultSet).

Posted by Valeriy Bashkatov on 28-Jan-2015 03:21

Hi Paul,

Thank you!

I will try this also.

Regards,

Valeriy

This thread is closed