16.10.2015 Views

Getting Started with DB2 Express-C

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

246 <strong>Getting</strong> <strong>Started</strong> <strong>with</strong> <strong>DB2</strong> <strong>Express</strong>-C<br />

The question mark (?) in the statement is known as a parameter marker. Using parameter<br />

markers, the program could prepare the statement only once, and then issue EXECUTE<br />

statements providing the different values for the parameter marker.<br />

In <strong>DB2</strong> 9.7, <strong>DB2</strong> introduced a technology called statement concentrator where all the<br />

statements that are the same except for the field values are automatically lumped together<br />

into one single statement <strong>with</strong> parameter markers, and then EXECUTE statements are<br />

performed <strong>with</strong> the different values. The statement concentrator does have the intelligence<br />

to determine when not to lump some statements together; for example, when you<br />

purposely add some clauses to influence the <strong>DB2</strong> optimizer.<br />

With respect to performance, Static SQL will normally perform better than dynamic SQL<br />

since the access plan in static SQL is performed at precompile time and not at runtime.<br />

However, for environments where there is a lot of activity such as INSERTs and DELETEs,<br />

the statistics calculated at precompile time may not be up-to-date, and therefore, the<br />

access plan of the static SQL may not be optimal. In this case, dynamic SQL may be a<br />

better choice, assuming a RUNSTATS command is frequently executed to collect current<br />

statistics.<br />

Note:<br />

Many users think embedded SQL is only static. In reality, it can be both, static or dynamic.<br />

14.3.3 CLI and ODBC<br />

Call Level Interface (CLI) was originally developed by the X/Open Company and the SQL<br />

Access Group. It was a specification for a callable SQL interface <strong>with</strong> the purpose of<br />

developing portable C/C++ applications regardless of the RDBMS vendor. Based on a<br />

preliminary draft of X/Open Call Level Interface, Microsoft developed Open Database<br />

Connectivity (ODBC), and later on, the ISO CLI International Standard accepted most of<br />

the X/Open Call Level Interface specification. <strong>DB2</strong> CLI is based on both: ODBC and the<br />

International Standard for SQL/CLI as shown in Figure 14.3.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!