Using Dynamic SQL

Before you decide to use dynamic SQL, some consideration should be taken for whether using static SQL or dynamic SQL is the best technique for the application. For most DB2 users, static SQLembedded in a host language program and bound before the program runs—provides a straightforward, efficient path to DB2 data. Static SQL should be used when the SQL statements the application needs to execute are known before runtime.

Dynamic SQL prepares and executes the SQL statements within a program while the program is running. There are four types of dynamic SQL:

  • Embedded dynamic SQL: The application puts the SQL source in host variables and includes PREPARE and EXECUTE statements that tell DB2 to prepare and run the contents of those ...

Get DB2® Universal Database™ for OS/390™ v7.1 Application Certification Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.