Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Persisting Result Sets as XML Data Files DataDirect Connect® Series ODBC Drivers Introduction DataDirect Connect® Series ODBC drivers (DataDirect Connect for ODBC and DataDirect Connect64 for ODBC) include a feature that 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 (see following figure). This can be accomplished by simply adding one or two lines of code to existing ODBC applications. ODBC Application DataDirect Connect for ODBC Driver Result Set XML Data File Result Set Relational Database DataDirect Connect for ODBC Drivers are currently the only ODBC drivers on the market that can persist result sets as XML data files. Benefits of Using DataDirect Connect ® Series ODBC Drivers to Persist Data as XML 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. DataDirect Technologies provides a simple way for you to use existing data and publish it on the Web. You do not have to replicate the data or manually reformat it—you just add one or two lines of code to your existing ODBC application and an XML data file is created. P E R S I S T I N G R E S U L T S E T S A S X M L D A T A F I L E S XML allows you to use the power of the Web to provide up-to-date information to your colleagues within the same organization, your outside partners, and your customers. For example, instead of e-mailing a textformatted report to sales representatives in the field, you can publish daily sales information in an XML report on a secure Web page, which is accessible to a PC, a laptop, or a handheld device. Creating XML from data stored in a relational database offers a way for you to: Quickly publish information (such as up-to-date price lists or current inventory totals) to the Web Allow customers to interact with the data you publish on the Web Scenario In this scenario, a wholesaler decides to provide an online catalog over the Web. The wholesaler chooses XML for the format of the catalog because XML provides semantics to the online catalog information that will allow the customer to do business with the wholesaler online. The wholesaler's catalog information is stored natively in an Oracle relational database inside the wholesaler's Internet firewall. Through an ODBC application using a DataDirect Connect Series ODBC Oracle driver, the wholesaler retrieves the data from the relational database and publishes that information to the Web Server as an XML data file in the form of an online catalog. To do this, the ODBC application issues a SQL Select statement, for example: SQLExecDirect (hstmt, "Select ITEM_NO, PRICE, DESCRIPTION, PHOTO FROM ALL_STOCK ORDER BY 3", SQL_NTS) Once the wholesaler has published the catalog on the Web as an XML data file, the customer can view the catalog using any XML-enabled browser. More important, customers can deal with the wholesaler more efficiently by using applications to interact with the catalog just as if they had direct access to the wholesaler’s relational database. The wholesaler develops and distributes to his customers an ODBC application that: Connects to a URL that specifies the wholesaler’s XML catalog Checks the price and availability of any item in the wholesaler’s catalog Places the order if the item is in stock In addition, the customer could develop custom applications to interact with the wholesaler’s catalog, applications that fit the exact needs of the customer. 2 OF 5 D A T A D I R E C T T E C H N O L O G I E S MAY 04 P E R S I S T I N G R E S U L T S E T S A S X M L D A T A F I L E S In this scenario, both the wholesaler and consumer benefit by the wholesaler’s catalog being published to the Web using XML. And, DataDirect Connect Series ODBC drivers provide a way to persist data easily from a relational database to XML. Implementing XML Persistence This section provides step-by-step instructions for implementing XML persistence in an ODBC application using a DataDirect Connect for ODBC Driver. 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:\temp\GTABLE.XML", SQL_NTS) NOTE: A statement attribute is available to support XML persistence, SQL_PERSIST_AS_XML. A client application must call SQLSetStmtAttr with this attribute as an argument. See the following table for the definition of valid arguments for SQLSetStmtAttr. D A T A D I R E C T Argument Definition StatementHandle The handle of the statement that contains the result set to persist as XML. Attribute SQL_PERSIST_AS_XML. This 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. T E C H N O L O G I E S MAY 04 3 OF 5 P E R S I S T I N G R E S U L T S E T S A S X M L D A T A F I L E S An ODBC application can persist the data at any time that the statement is in an executed or cursor-positioned state. Summary DataDirect Connect Series ODBC drivers include the ability to persist result sets as XML data files for the leading databases: Oracle, Informix, DB2, and Sybase. The benefit to you is that you can quickly publish information to the Web and allow customers to interact with the data you publish. Currently, DataDirect Technologies provides the only ODBC drivers on the market that provide this functionality. We welcome your feedback! Please send any comments concerning documentation, including suggestions for other topics that you would like to see, to: [email protected] 4 OF 5 D A T A D I R E C T T E C H N O L O G I E S MAY 04 P E R S I S T I N G R E S U L T S E T S A S X M L D A T A F I L E S FOR MORE INFORMATION 800-876-3101 DataDirect Technologies is focused on data access, enabling software developers at both packaged software vendors and in corporate IT departments to create better applications faster. DataDirect Technologies offers the most comprehensive, proven line of data connectivity components available anywhere. Developers worldwide depend on DataDirect Technologies to connect their applications to an unparalleled range of data sources using standards-based interfaces such as ODBC, JDBC and ADO.NET, as well as cutting-edge XML query technologies. More than 250 leading independent software vendors and thousands of enterprises rely on DataDirect Technologies to simplify and streamline data connectivity. DataDirect Technologies is an operating company of Progress Software Corporation (Nasdaq: PRGS). [email protected] Worldwide Sales Belgium (French) ..............0800 12 045 Belgium (Dutch)................0800 12 046 France .............................0800 911 454 Germany .....................0800 181 78 76 Japan ..............................0120.20.9613 Netherlands ..................0800 022 0524 United Kingdom ..........0800 169 19 07 United States..................800 876 3101 www.datadirect.com Copyright © 2004 DataDirect Technologies Corp. All rights reserved. DataDirect Connect is a registered trademark of DataDirect Technologies Corp. in the United States and other countries. Java and all Java based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. Other company or product names mentioned herein may be trademarks or registered trademarks of their respective companies. D A T A D I R E C T T E C H N O L O G I E S MAY 04 5 OF 5