1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
|
<HTML>
<HEAD>
<TITLE>prguide.htm</TITLE>
<LINK REL="ToC" HREF="httoc.htm">
<LINK REL="Index" HREF="htindex.htm">
<LINK REL="Next" HREF="prguide2.htm">
<LINK REL="Previous" HREF="prguide.htm"></HEAD>
<BODY BGCOLOR="#FFFFFF">
<P ALIGN=CENTER>
<A HREF="prguide.htm" TARGET="_self"><IMG SRC="graprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>
<A HREF="httoc.htm" TARGET="_self"><IMG SRC="gratoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>
<A HREF="htindex.htm" TARGET="_self"><IMG SRC="graindex.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Index"></A>
<A HREF="prguide2.htm" TARGET="_self"><IMG SRC="granext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>
<HR ALIGN=CENTER>
<P>
<UL>
<LI>
<A HREF="#E9E2" >Theory of Operation</A>
<UL>
<LI>
<A HREF="#E10E6" >SOLID SQL API</A>
<LI>
<A HREF="#E10E7" >SOLID SQL API and ODBC Interface</A>
<LI>
<A HREF="#E10E8" >ODBC History</A>
<LI>
<A HREF="#E10E9" >ODBC Interface</A>
<LI>
<A HREF="#E10E10" >ODBC Components</A>
<UL>
<LI>
<A HREF="#E11E1" >Application</A>
<LI>
<A HREF="#E11E2" >Driver Manager</A>
<LI>
<A HREF="#E11E3" >Driver</A>
<LI>
<A HREF="#E11E4" >Data Source</A></UL>
<LI>
<A HREF="#E10E11" >Matching an Application to a Driver</A>
<UL>
<LI>
<A HREF="#E11E5" >ODBC Conformance Levels</A>
<UL>
<LI>
<A HREF="#E12E1" >API Conformance Levels</A>
<LI>
<A HREF="#E12E2" >SQL Conformance Levels</A></UL>
<LI>
<A HREF="#E11E6" >How to Select a Set of Functionality</A>
<LI>
<A HREF="#E11E7" >Connections and Transactions</A></UL></UL></UL>
<HR ALIGN=CENTER>
<A NAME="E9E2"></A>
<H1>
<FONT FACE="Arial"><B>THEORY OF OPERATION</B></FONT></H1>
<BR>
<BLOCKQUOTE>
<P><A NAME="I2"></A>SOLID <I>SQL API</I> is the native call level interface of SOLID DBMS. SOLID <I>SQL API</I> is based on the SQL Access Group's CLI specification, a standard dynamic call level interface. The SQL syntax used in SOLID <I>Server</I> is based on the ANSI X3.135-1989 level 2 standard including important ANSI X3.135-1992 (SQL2) extensions. Developers have also the option of accessing SQL <I>SQL API</I> through ODBC API in the Windows (3.x, NT and 95) environments. ODBC provides a single interface for SQL queries to access a variety of relational and non-relational databases.
</BLOCKQUOTE>
<A NAME="E7E15"></A>
<P><B>SAG CLI History</B>
<BLOCKQUOTE>
<P>The SQL Access Group (SAG) was formed in 1989 to define and promote standards for database portability and interoperability. The group's initial projects involved developing the draft ISO/ANSI standard for SQL (including the embedded-SQL interface specifications) and a specification for remote data access (RDA).
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>In 1990, SAG took the lead in developing an SQL-based Call Level Interface (CLI). The SAG CLI is and API for database access, offering an alternative invocation technique to embedded SQL that provides essentially equivalent operations. SAG envisioned an interface that would enable client/server applications to access data stored in heterogeneous relational and nonrelational databases. The interface would be platform, vendor, database and language neutral. SAG and X/Open published the CLI Snapshot Specification in 1992 as a "work in progress", and it was adopted for use in commercial software products.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Microsoft helped to define the X/Open CLI specification and became the first company to commercialize the CLI specification by shipping ODBC 1.0 for Windows in 1992. To create ODBC, Microsoft extended the CLI specification and created a three-layer specification in which the "core" layer corresponds to the SAG CLI. Over the next two years, the CLI specification underwent several transformations, reemerging in 1994 as an X/Open Preliminary Specification. Also in 1994, Microsoft released ODBC 2.0, whose core functionality was still aligned with the SAG CLI. In 1996, Microsoft announced that ODBC 3.0 will be fully aligned with both ISO's CLI standard and SAG's CLI Specification.
</BLOCKQUOTE>
<A NAME="E10E6"></A>
<H2>
<FONT FACE="Arial"><B>SOLID </B><B><I>SQL API</I></B></FONT></H2>
<BLOCKQUOTE>
<P>SOLID <I>SQL API</I> is a DLL for Windows and OS/2, and a library for other environents. <I>SOLID SQL API</I> has functions that support a rich set of database access operations sufficient to creating robust database applications, including:
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI>Allocating and deallocating handles
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Getting and setting attributes
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Opening and closing database connections
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Accessing descriptors
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Executing SQL statements
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Accessing schema metadata
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Controlling transactions
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Accessing diagnostic information
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Cancelling functions
</BLOCKQUOTE></UL>
<BLOCKQUOTE>
<P>A database application calls these functions for all interactions with a database. SOLID <I>SQL API</I> enables applications to establish multiple database connections simultaneously and to process multiple statements simultaneously.
</BLOCKQUOTE>
<BLOCKQUOTE>
<H4>
<FONT FACE="Arial"><B>Using SOLID </B><B><I>SQL API</I></B></FONT></H4>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The application allocates memory for an environment handle and a connection handle; both are required to establish a database connection. The <B>SQLConnect</B> call establishes the database connection, specifying the server name, user id, and password. The application then allocates memory for a statement handle and calls either <B>SQLExecDirect</B>, which both prepares and executes an SQL statement, or <B>SQLPrepare</B> and <B>SQLExecute</B>, which allows statements to be executed multiple times. If the statement was a SELECT statement, the resulting columns need to be bound to variables in the application. This is done by using <B>SQLBindCol</B>. The rows can be then fetched using repeatedly <B>SQLFetch</B>.If the statement was a UPDATE, DELETE or INSERT, the application needs to check if the execution succeeded and call<B> SQLTransact</B> to commit the transaction. Finally the application closes the connection.
</BLOCKQUOTE>
<A NAME="E10E7"></A>
<H2>
<FONT FACE="Arial"><B>SOLID </B><B><I>SQL API</I></B><B> and ODBC Interface</B><A NAME="I3"></A></FONT></H2>
<BLOCKQUOTE>
<P>The Open Database Connectivity (ODBC) interface allows applications to access data in database management systems (DBMS) using Structured Query Language (SQL) as a standard for accessing data.<A NAME="I4"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The interface permits maximum <I>interoperability</I> — a single application can access different database management systems. This allows an application developer to develop, compile, and ship an application without targeting a specific DBMS. Users can then add modules called database <I>drivers </I>that link the application to their choice of database management systems.
</BLOCKQUOTE>
<BLOCKQUOTE>
<H4>
<FONT FACE="Arial"><B>Accessing SOLID </B><B><I>SQL API</I></B><B> through ODBC API</B></FONT></H4>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Native 16 and 32 bit ODBC drivers are available for maximum power and functionality. When SOLID SQL API is accessed through ODBC API developers can use also those ODBC functions that are implemented in the ODBC Driver Manager.
</BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<NOTE>The ODBC interface can be used in Windows 3.x, Windows 95 and Windows NT clients.</NOTE>
<HR ALIGN=CENTER>
</BLOCKQUOTE>
<A NAME="E10E8"></A>
<H2>
<FONT FACE="Arial"><B>ODBC History</B><A NAME="I5"></A><A NAME="I6"></A><A NAME="I7"></A></FONT></H2>
<BLOCKQUOTE>
<P>In the traditional database world, <I>application</I> has usually meant a program that performed a specific database task with a specific DBMS in mind such as payroll, financial analysis, or inventory management. Such applications have typically been written using embedded SQL. While embedded SQL is efficient and is portable across different hardware and operating system environments, the source code must be recompiled for each new environment.<A NAME="I8"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Embedded SQL is not optimal for applications that need to analyze data stored in databases such as DB2® and Oracle®, and prefer to do so from within a familiar application interface, such as a Microsoft Excel® spreadsheet. Under the traditional approach to database access, one version of Microsoft Excel would have to be precompiled with the IBM® precompiler and another with the Oracle precompiler, clearly a radical departure from simply buying a single packaged product.<A NAME="I9"></A><A NAME="I10"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>ODBC offers a new approach: provide a separate program to extract the database information, and then have a way for applications to import the data. Since there are and probably always will be many viable communication methods, data protocols, and DBMS capabilities, the ODBC solution is to allow different technologies to be used by defining a standard interface. This solution leads to the idea of database drivers — dynamic-link libraries that an application can invoke on demand to gain access to a particular data source through a particular communications method, much like a printer driver running under Windows. ODBC provides the standard interface that allows both application writers and providers of libraries to shuttle data between applications and data sources.
</BLOCKQUOTE>
<A NAME="E10E9"></A>
<H2>
<FONT FACE="Arial"><B>ODBC Interface</B><A NAME="I11"></A></FONT></H2>
<BLOCKQUOTE>
<P>The ODBC interface defines the following:<A NAME="I12"></A>
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI>A library of ODBC function calls that allow an application to connect to a DBMS, execute SQL statements, and retrieve results.<A NAME="I13"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>SQL syntax based on the X/Open and SQL Access Group (SAG) SQL CAE specification (1992).<A NAME="I14"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>A standard set of error codes.<A NAME="I15"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>A standard way to connect and log on to a DBMS.<A NAME="I16"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>A standard representation for data types.<A NAME="I17"></A>
</BLOCKQUOTE></UL>
<BLOCKQUOTE>
<P>The interface is flexible:<A NAME="I18"></A>
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI>Strings containing SQL statements can be explicitly included in source code or constructed on the fly at run time.<A NAME="I19"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>The same object code can be used to access different DBMS products.<A NAME="I20"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>An application can ignore underlying data communications protocols between it and a DBMS product.<A NAME="I21"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Data values can be sent and retrieved in a format convenient to the application.<A NAME="I22"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>The ODBC interface provides two types of function calls:<A NAME="I23"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI><I>Core function</I>s are based on the X/Open and SQL Access Group Call Level Interface specification.<A NAME="I24"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI><I>Extended function</I>s support additional functionality, including scrollable cursors and asynchronous processing.<A NAME="I25"></A>
</BLOCKQUOTE></UL>
<BLOCKQUOTE>
<P>To send an SQL statement, include the statement as an argument in an ODBC function call. The statement need not be customized for a specific DBMS.
</BLOCKQUOTE>
<A NAME="E10E10"></A>
<H2>
<FONT FACE="Arial"><B>ODBC Components</B><A NAME="I26"></A><A NAME="I27"></A></FONT></H2>
<BLOCKQUOTE>
<P>The ODBC architecture has four components:<A NAME="I28"></A>
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI><B>Application</B> Performs processing and calls ODBC functions to submit SQL statements and retrieve results.<A NAME="I29"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI><B>Driver Manager</B><B> </B>Loads drivers on behalf of an application.<A NAME="I30"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI><B>Driver</B><B> </B>Processes ODBC function calls, submits SQL requests to a specific data source, and returns results to the application. If necessary, the driver modifies an application’s request so that the request conforms to syntax supported by the associated DBMS.<A NAME="I31"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI><B>Data source</B><B> </B>Consists of the data the user wants to access and its associated operating system, DBMS, and network platform (if any) used to access the DBMS.<A NAME="I32"></A>
</BLOCKQUOTE></UL>
<BLOCKQUOTE>
<P>The Driver Manager and driver appear to an application as one unit that processes ODBC function calls. The following paragraphs describe each component in more detail.
</BLOCKQUOTE>
<A NAME="E11E1"></A>
<H3>
<FONT FACE="Arial">Application<A NAME="I33"></A><A NAME="I34"></A><A NAME="I35"></A></FONT></H3>
<BLOCKQUOTE>
<P>An application using the ODBC interface performs the following tasks:<A NAME="I36"></A>
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI>Requests a connection, or session, with a data source.<A NAME="I37"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Sends SQL requests to the data source.<A NAME="I38"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Defines storage areas and data formats for the results of SQL requests.<A NAME="I39"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Requests results.<A NAME="I40"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Processes errors.<A NAME="I41"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Reports results back to a user, if necessary.<A NAME="I42"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Requests commit or rollback operations for transaction control.<A NAME="I43"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Terminates the connection to the data source.<A NAME="I44"></A>
</BLOCKQUOTE></UL>
<BLOCKQUOTE>
<P>An application can provide a variety of features external to the ODBC interface, including mail, spreadsheet capabilities, online transaction processing, and report generation; the application may or may not interact with users.
</BLOCKQUOTE>
<A NAME="E11E2"></A>
<H3>
<FONT FACE="Arial">Driver Manager<A NAME="I45"></A><A NAME="I46"></A><A NAME="I47"></A></FONT></H3>
<BLOCKQUOTE>
<P>The Driver Manager, provided by Microsoft, is a dynamic-link library (DLL) with an import library. The primary purpose of the Driver Manager is to load drivers. The Driver Manager also performs the following:<A NAME="I48"></A>
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI>Uses the ODBC.INI file or registry to map a data source name to a specific driver dynamic-link library (DLL).<A NAME="I49"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Processes several ODBC initialization calls.<A NAME="I50"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Provides entry points to ODBC functions for each driver.<A NAME="I51"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Provides parameter validation and sequence validation for ODBC calls.
</BLOCKQUOTE></UL>
<A NAME="E11E3"></A>
<H3>
<FONT FACE="Arial">Driver<A NAME="I52"></A><A NAME="I53"></A><A NAME="I54"></A></FONT></H3>
<BLOCKQUOTE>
<P>A driver is a DLL that implements ODBC function calls and interacts with a data source.<A NAME="I55"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The Driver Manager loads a driver when the application calls the <B>SQLBrowseConnect</B>, <B>SQLConnect</B>, or <B>SQLDriverConnect</B> function.<A NAME="I56"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>A driver performs the following tasks in response to ODBC function calls from an application:<A NAME="I57"></A>
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI>Establishes a connection to a data source.<A NAME="I58"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Submits requests to the data source.<A NAME="I59"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Translates data to or from other formats, if requested by the application.<A NAME="I60"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Returns results to the application.<A NAME="I61"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Formats errors into standard error codes and returns them to the application.<A NAME="I62"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Declares and manipulates cursors if necessary. (This operation is invisible to the application unless there is a request for access to a cursor name.)<A NAME="I63"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Initiates transactions if the data source requires explicit transaction initiation. (This operation is invisible to the application.)
</BLOCKQUOTE></UL>
<A NAME="E11E4"></A>
<H3>
<FONT FACE="Arial">Data Source<A NAME="I64"></A><A NAME="I65"></A><A NAME="I66"></A></FONT></H3>
<BLOCKQUOTE>
<P>In this manual, <I>DBMS</I> refers to the general features and functionality provided by an SQL database management system. A <I>data source</I> is a specific instance of a combination of a DBMS product and any remote operating system and network necessary to access it.<A NAME="I67"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>An application establishes a connection with a particular vendor’s DBMS product on a particular operating system, accessible by a particular network. For example, the application might establish connections to:<A NAME="I68"></A>
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI>An Oracle DBMS running on an OS/2® operating system, accessed by Novell® netware.<A NAME="I69"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>A local Xbase file, in which case the network and remote operating system are not part of the communication path.<A NAME="I70"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>A Tandem NonStop<SUP>™</SUP> SQL DBMS running on the Guardian 90 operating system, accessed via a gateway.
</BLOCKQUOTE></UL>
<A NAME="E10E11"></A>
<H2>
<FONT FACE="Arial"><B>Matching an Application to a Driver</B><A NAME="I71"></A></FONT></H2>
<BLOCKQUOTE>
<P>One of the strengths of the ODBC interface is interoperability; a programmer can create an ODBC application without targeting a specific data source. Users can add drivers to the application after it is compiled and shipped.<A NAME="I72"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>From an application standpoint, it would be ideal if every driver and data source supported the same set of ODBC function calls and SQL statements. However, data sources and their associated drivers provide a varying range of functionality. Therefore, the ODBC interface defines conformance levels, which determine the ODBC procedures and SQL statements supported by a driver.
</BLOCKQUOTE>
<A NAME="E11E5"></A>
<H3>
<FONT FACE="Arial">ODBC Conformance Levels<A NAME="I73"></A></FONT></H3>
<BLOCKQUOTE>
<P>ODBC defines conformance levels for drivers in two areas: the ODBC API and the ODBC SQL grammar (which includes the ODBC SQL data types). Conformance levels help both application and driver developers by establishing standard sets of functionality. Applications can easily determine if a driver provides the functionality they need. Drivers can be developed to support a broad selection of applications without being concerned about the specific requirements of each application.<A NAME="I74"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>To claim that it conforms to a given API or SQL conformance level, a driver must support all the functionality in that conformance level, regardless of whether that functionality is supported by the DBMS associated with the driver. However, conformance levels do not restrict drivers to the functionality in the levels to which they conform. Driver developers are encouraged to support as much functionality as they can; applications can determine the functionality supported by a driver by calling <B>SQLGetInfo</B>, <B>SQLGetFunctions</B>, and <B>SQLGetTypeInfo</B>.
</BLOCKQUOTE>
<BLOCKQUOTE>
<A NAME="E12E1"></A>
<H4>
<FONT>API Conformance Levels<A NAME="I75"></A><A NAME="I76"></A><A NAME="I77"></A><A NAME="I78"></A></FONT></H4>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The ODBC API defines a set of core functions that correspond to the functions in the X/Open and SQL Access Group Call Level Interface specification. ODBC also defines two extended sets of functionality, Level 1 and Level 2. The following list summarizes the functionality included in each conformance level.<A NAME="I79"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Core API<A NAME="I80"></A>
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI>Allocate and free environment, connection, and statement handles.<A NAME="I81"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Connect to data sources. Use multiple statements on a connection.<A NAME="I82"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Prepare and execute SQL statements. Execute SQL statements immediately.<A NAME="I83"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Assign storage for parameters in an SQL statement and result columns.<A NAME="I84"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Retrieve data from a result set. Retrieve information about a result set.<A NAME="I85"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Commit or roll back transactions.<A NAME="I86"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Retrieve error information.
</BLOCKQUOTE></UL>
<BLOCKQUOTE>
<P>Level 1 API<A NAME="I87"></A>
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI>Core API functionality.<A NAME="I88"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Connect to data sources with driver-specific dialog boxes.<A NAME="I89"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Set and inquire values of statement and connection options.<A NAME="I90"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Send part or all of a parameter value (useful for long data).<A NAME="I91"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Retrieve part or all of a result column value (useful for long data).<A NAME="I92"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Retrieve catalog information (columns, special columns, statistics, and tables).<A NAME="I93"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Retrieve information about driver and data source capabilities, such as supported data types, scalar functions, and ODBC functions.
</BLOCKQUOTE></UL>
<BLOCKQUOTE>
<P>Level 2 API<A NAME="I94"></A>
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI>Core and Level 1 API functionality.<A NAME="I95"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Browse connection information and list available data sources.<A NAME="I96"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Send arrays of parameter values. Retrieve arrays of result column values.<A NAME="I97"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Retrieve the number of parameters and describe individual parameters.<A NAME="I98"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Use a scrollable cursor.<A NAME="I99"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Retrieve the native form of an SQL statement.<A NAME="I100"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Retrieve catalog information (privileges, keys, and procedures).<A NAME="I101"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Call a translation DLL.<A NAME="I102"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>For a list of functions and their conformance levels, see<I> </I>Chapter 12, "Function Summary."<A NAME="I103"></A>
</BLOCKQUOTE></UL>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<NOTE>Note Each function description in this manual indicates whether the function is a core function or a level 1 or level 2 extension function.</NOTE>
<HR ALIGN=CENTER>
</BLOCKQUOTE>
<BLOCKQUOTE>
<A NAME="E12E2"></A>
<H4>
<FONT>SQL Conformance Levels<A NAME="I104"></A><A NAME="I105"></A><A NAME="I106"></A></FONT></H4>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>ODBC defines a core grammar that roughly corresponds to the X/Open and SQL Access Group SQL CAE specification (1992). ODBC also defines a minimum grammar, to meet a basic level of ODBC conformance, and an extended grammar, to provide for common DBMS extensions to SQL. The following list summarizes the grammar included in each conformance level.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Minimum SQL Grammar<A NAME="I107"></A><A NAME="I108"></A><A NAME="I109"></A>
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI>Data Definition Language (DDL): <B>CREATE TABLE</B> and <B>DROP </B>TABLE.<A NAME="I110"></A><A NAME="I111"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Data Manipulation Language (DML): simple <B>SELECT</B>, <B>INSERT</B>, <B>UPDATE</B> <B>SEARCHED</B>, and <B>DELETE SEARCHED</B>.<A NAME="I112"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Expressions: simple (such as <B>A > B + C</B>).<A NAME="I113"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Data types: CHAR, VARCHAR, or LONG VARCHAR.
</BLOCKQUOTE></UL>
<BLOCKQUOTE>
<P>Core SQL Grammar<A NAME="I114"></A>
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI>Minimum SQL grammar and data types.<A NAME="I115"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>ALTER TABLE, CREATE INDEX, DROP INDEX, CREATE VIEW, DROP VIEW, GRANT, and REVOKE.<A NAME="I116"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>full <B>SELECT</B>.<A NAME="I117"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Expressions: subquery, set functions such as <B>SUM</B> and <B>MIN</B>.<A NAME="I118"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Data types: DECIMAL, NUMERIC, SMALLINT, INTEGER, REAL, FLOAT, DOUBLE PRECISION.
</BLOCKQUOTE></UL>
<BLOCKQUOTE>
<P>Extended SQL Grammar<A NAME="I119"></A>
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI>Minimum and Core SQL grammar and data types.<A NAME="I120"></A><A NAME="I121"></A><A NAME="I122"></A><A NAME="I123"></A><A NAME="I124"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>outer joins, positioned <B>UPDATE</B>, positioned <B>DELETE</B>, <B>SELECT FOR </B><B>UPDATE</B>, and unions.
</BLOCKQUOTE></UL>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<NOTE><A NAME="I125"></A>Note In ODBC 1.0, positioned update, positioned delete, and <B>SELECT FOR </B><B>UPDATE</B> statements and the <B>UNION</B> clause were part of the core SQL grammar; in ODBC 2.0, they are part of the extended grammar. Applications that use the SQL conformance level to determine whether these statements are supported also need to check the version number of the driver to correctly interpret the information. In particular, applications that use these features with ODBC 1.0 drivers need to explicitly check for these capabilities in ODBC 2.0 drivers.<A NAME="I126"></A></NOTE>
<HR ALIGN=CENTER>
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI>Expressions: scalar functions such as <B>SUBSTRING</B> and <B>ABS</B>, date, time, and timestamp literals.<A NAME="I127"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Data types: BIT, TINYINT, BIGINT, BINARY, VARBINARY, LONG VARBINARY, DATE, TIME, TIMESTAMP<A NAME="I128"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Batch SQL statements.<A NAME="I129"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Procedure calls.<A NAME="I130"></A>
</BLOCKQUOTE></UL>
<BLOCKQUOTE>
<P>For more information about data types, see Appendix D, "Data Types."
</BLOCKQUOTE>
<A NAME="E11E6"></A>
<H3>
<FONT FACE="Arial">How to Select a Set of Functionality<A NAME="I131"></A><A NAME="I132"></A><A NAME="I133"></A></FONT></H3>
<BLOCKQUOTE>
<P>The ODBC functions and SQL statements that a driver supports usually depend on the capabilities of its associated data source. Driver developers are encouraged, however, to implement as many ODBC functions as possible to ensure the widest possible use by applications.<A NAME="I134"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The ODBC functions and SQL statements that an application uses depend on:<A NAME="I135"></A>
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI>The functionality needed by the application.<A NAME="I136"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>The performance needed by the application.<A NAME="I137"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>The data sources to be accessed by the application and the extent to which the application must be interoperable among these data sources.<A NAME="I138"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>The functionality available in the drivers used by the application.<A NAME="I139"></A>
</BLOCKQUOTE></UL>
<BLOCKQUOTE>
<P>Because drivers support different levels of functionality, application developers may have to make trade-offs among the factors listed above. For example, an application might display the data in a table. It uses <B>SQLColumnPrivileges</B> to determine which columns a user can update and dims those columns the user cannot update. If some of the drivers available to the developer of this application do not support <B>SQLColumnPrivileges</B>, the developer can decide to:<A NAME="I140"></A>
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI>Use all the drivers and not dim any columns. The application behaves the same for all data sources, but has reduced functionality: the user might attempt to update data in a column for which they do not have update privileges. The application returns an error message only when the driver attempts to update the data in the data source.<A NAME="I141"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Use only those drivers that support <B>SQLColumnPrivileges</B>. The application behaves the same for all supported data sources, but has reduced functionality: the application does not support all the drivers.<A NAME="I142"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Use all the drivers and, for drivers that support <B>SQLColumnPrivileges</B>, dim columns the user cannot update. Otherwise, warn the user that they might not have update privileges on all columns. The application behaves differently for different data sources but has increased functionality: the application supports all drivers and sometimes dims columns the user cannot update.<A NAME="I143"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>Use all the drivers and always dim columns the user cannot update; the application locally implements <B>SQLColumnPrivileges</B> for those drivers that do not support it. The application behaves the same for all data sources and has maximum functionality. However, the developer must know how to retrieve column privileges from some of the data sources, the application contains data source–specific code, and developement time is longer.<A NAME="I144"></A>
</BLOCKQUOTE></UL>
<BLOCKQUOTE>
<P>Developers of specialized applications may make different trade-offs than developers of generalized applications. For example, the developer of an application that only transfers data between two DBMS’s (each from a different vendor) can safely exploit the full functionality of each of the drivers.
</BLOCKQUOTE>
<A NAME="E11E7"></A>
<H3>
<FONT FACE="Arial">Connections and Transactions</FONT></H3>
<A NAME="I145"></A><A NAME="I146"></A>
<BLOCKQUOTE>
<P>Before an application can use ODBC, it must initialize ODBC and request an environment handle (<I>henv</I>). To communicate with a data source, the application must request a connection handle <A NAME="I147"></A>(<I>hdbc</I>) and connect to the data source. The application uses the environment and connection handles in subsequent ODBC calls to refer to the environment and specific connection.
</BLOCKQUOTE>
<A NAME="E7E16"></A>
<P><A NAME="I148"></A>
<BLOCKQUOTE>
<P>An application may request multiple connections for one or more data sources. Each connection is considered a separate transaction space.<A NAME="I149"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>An active connection can have one or more statement processing streams.<A NAME="I150"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>A driver maintains a transaction for each active connection. The application can request that each SQL statement be automatically committed on completion; otherwise, the driver waits for an explicit commit or rollback request from the application. When the driver performs a commit or rollback operation, the driver resets all statement requests associated with the connection.<A NAME="I151"></A>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The Driver Manager manages the work of allowing an application to switch connections while transactions are in progress on the current connection.
</BLOCKQUOTE><P ALIGN=CENTER>
<A HREF="prguide.htm" TARGET="_self"><IMG SRC="graprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>
<A HREF="httoc.htm" TARGET="_self"><IMG SRC="gratoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>
<A HREF="htindex.htm" TARGET="_self"><IMG SRC="graindex.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Index"></A>
<A HREF="prguide2.htm" TARGET="_self"><IMG SRC="granext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>
<center><p><font SIZE=-2>Copyright © 1992-1997 Solid Information Technology Ltd All rights reserved.</font></p></center>
</BODY></HTML>
|