Full name
Henning Ørnsø
Submitted by Henning Ørnsø on Thu, 02/02/2012 - 00:00
Forums

Hi,

Can I connect to a Microsoft SQL server or MySql from an IceBreak program?

Best regards,

Henning Ørnsø 

Niels Liisberg

Thu, 02/02/2012 - 00:00

Hi Henning;

IceBreak supports a build in version of the "Call Level Interface" (CLI) which is used by JDBC and ODBC to connect to remote databased. Basically you can connect to any JDB/ODBC kind of databases with that technology, you will however need to set up the connection string to the remote server. You will need a little "google search" to find that settings for your particular database.

The following sample will return a XML document directly to the response object from the local DB/2 database because the Connection string is empty. If you provide a connection string with remote location and port you can pull data from MS-Sql, MySql, Oracle and of cause DB/2:

<%
d sqlOptions      ds                  likeds(SQL_options)
d err             s               N
/free
  SetContentType('application/xml; charset=utf-8');  // Only utf-8 is supported!!
  sqlOptions = *loval;            // always initialize before use to hex 0x00
  sqlOptions.Format    = I_XML;   // Output format I_XML, I_JSON …
  sqlOptions.Limit     = 99999;   // Max number of rows to return
  sqlOptions.Start     = 1;       // Starting from row number
  sqlOptions.HexSort   = *ON;     // *ON, use binary indexes( logical files), *OFF use language *JOB
  sqlOptions.Connect   = '';      // Optional ODBC connections string to external databases
  sqlOptions.SqlNaming = *OFF;    // *ON use '.' between library and table. *OFF use '/'
  sqlOptions.sqlCmd    = (' +     // The select command to run
    Select * from ICEQSAMPLE/DBCSTEST   +
  ');

  err = SQL_Execute2(sqlOptions);
  *inlr = *ON;

%>

Best regards,

Niels Liisberg