16.10.2015 Views

Getting Startedwith pureQuery

Create successful ePaper yourself

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

Appendix D – Static SQL in DB2 351<br />

Figure D.18 - Dynamic SQL statement string and its access plan are determined at<br />

runtime.<br />

On the other hand, static sections are pre-associated with an SQL string. A static section<br />

will only be used to execute the single SQL string defined in the section itself, and the<br />

section will use the access plan that was pre-determined when the package was defined<br />

(precompiled and bound) in the database server. This reduces the number of runtime<br />

steps required to execute the statement. In Figure D.7, three static packages are depicted<br />

in the DBMS. Each package contains sections with predetermined SQL strings and access<br />

plans, managed by the database catalog and package directory. The application does not<br />

need to send the SQL string at runtime or perform the steps required to ensure an access<br />

plan is created at runtime (prepare). The application simply identifies which predefined<br />

statement (identified by its package and section number) to execute. The figure shows a<br />

statement in the Payroll package being executed. DB2 will check the package<br />

authorizations, retrieve the SQL string and plan and execute the statement immediately.

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

Saved successfully!

Ooh no, something went wrong!