Tip

Implementing XML Persistence

Implementing XML Persistence
John Goodson

With the addition of one or two lines of code to existing ODBC applications, you can use a new feature in MERANT's DataDirect Connect ODBC 3.7 drivers to retrieve result sets from a relational database (such as Oracle, Informix, DB2, or Sybase) and store the result sets as XML data files.

A new feature in MERANT's DataDirect Connect ODBC 3.7 release enables you to retrieve result sets from a relational database (such as Oracle, Informix, DB2, or Sybase) and store the result sets as XML data files. You don't have to replicate the data or manually reformat the data-you just add one or two lines of code to your existing ODBC application and an XML data file is created.

The ODBC application must:

1. Turn on STATIC cursors. For example:
SQLSetStmtAttr (hstmt, SQL_ATTR_CURSOR_TYPE, SQL_CURSOR_STATIC, SQL_IS_INTEGER)

Note: A result set can be persisted as an XML data file only if the result set is generated using STATIC cursors.

2. Execute a SQL statement. For example:
SQLExecDirect (hstmt, "Select * from GTABLE", SQL_NTS)

3. Persist the result set as an XML data file. For example:
SQLSetStmtAttr (hstmt, SQL_PERSIST_AS_XML, "c:tempGTABLE.XML", SQL_NTS)

Note: A new statement attribute is available to support XML persistence, SQL_PERSIST_AS_XML. A client application must call SQLSetStmtAttr

    Requires Free Membership to View

with this new attribute as an argument. See the following table for the definition of valid arguments for SQLSetStmtAttr.

Argument Definition
StatementHandle The handle of the statement that contains the result set to persist as XML.
Attribute SQL_PERSIST_AS_XML. This new statement attribute can be found in the file qesqlext.h, which is installed with the driver.
ValuePtr Pointer to a URL that specifies the full path name of the XML data file to be generated. The directory specified in the path name must exist, and if the specified file name exists, the file will be overwritten.
StringLength The length of the string pointed to by ValuePtr or SQL_NTS if ValuePtr points to a null terminated string.

An ODBC application can choose to persist the data at any time that the statement is in an executed or cursor-positioned state.

The ability to persist result sets as XML data files helps you take advantage of XML faster as you adopt advanced B2B and B2C business processes on the Web. MERANT Connect ODBC drivers provide a simple way for you to use existing data and publish it on the Web. You just add one or two lines of code to your existing ODBC application and an XML data file is created.

John Goodson is vice president of research and development for the enterprise data connectivity technologies at MERANT, a leading provider of software solutions for enterprise change management; development, transformation and integration of legacy applications; and data connectivity. MERANT provides advanced data connectivity based on industry standards like ODBC, JDBC and ADO, to the commercial market.

Did you like this tip? We'd like to know what you think, so if you email us we can find out.

Related Books

OLE DB and ODBC Developer's Guide
Author: Chuck Wood
Publisher: Hungry Minds
Published : Oct 1999
Summary:
Starting where most books end, this savvy guide shows you how to hone your Visual C++ 6 data-access skills and develop sophisticated programs with new OLE DB and COM components, as well as the more traditional ODBC technologies.


This was first published in May 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.