CS2203 Discussion 8
Static or Embedded SQL are SQL statements in an application that do not change at runtime
and, therefore, can be hard-coded into the application. Using Static SQL has a benefit which is
the optimization of the statement that results an application with high performance as it offers a
good flexibility. (GeeksforGeeks, n.d.)
Dynamic SQL is SQL statements that are constructed at runtime; for example, the application
may allow users to enter their own queries. Dynamic SQL allows you to create more general
purpose, flexible applications because the full text of a SQL statement may be unknown at
compilation. (GeeksforGeeks ,n.d.)
Limitation of Dynamic SQL:
We cannot use some of the SQL statements Dynamically.
Performance of these statements is poor as compared to Static SQL.
Limitations of Static SQL:
They do not change at runtime thus are hard-coded into applications. (GeeksforGeeks ,n.d.)
Differences between Static SQL and Dynamic SQL
Static (Embedded) SQL Dynamic (Interactive) SQL
In Static SQL, how database will be accessed is In Dynamic SQL, how database will be
predetermined in the embedded SQL statement. accessed is determined at run time.
It is swifter and more efficient. It is less swift and efficient.
SQL statements are compiled at compile time. SQL statements are compiled at run time.
Parsing, Validation, Optimization and Parsing, Validation, Optimization and
Generation of application plan are done at Generation of application plan are done at run
compile time. time.
It is generally used for situations where data is It is generally used for situations where data is
distributed uniformly. distributed non uniformly.
EXECUTE IMMEDIATE, EXECUTE and EXECUTE IMMEDIATE, EXECUTE and
PREPARE statements are not used. PREPARE statements are used.
It is less flexible. It is more flexible.
(GeeksforGeeks ,n.d.)
Features and examples:
"Static SQL is the most traditional way of building embedded SQL applications. Static SQL
applications are designed for scenarios where the applications need to issue the same SQL
statements every time it interacts with the database. For example, an application which updates
the inventory stock, would always issue the same SQL statement to add new stock. Similarly, an
online reservation system would always update the same table and mark the same column as
Static or Embedded SQL are SQL statements in an application that do not change at runtime
and, therefore, can be hard-coded into the application. Using Static SQL has a benefit which is
the optimization of the statement that results an application with high performance as it offers a
good flexibility. (GeeksforGeeks, n.d.)
Dynamic SQL is SQL statements that are constructed at runtime; for example, the application
may allow users to enter their own queries. Dynamic SQL allows you to create more general
purpose, flexible applications because the full text of a SQL statement may be unknown at
compilation. (GeeksforGeeks ,n.d.)
Limitation of Dynamic SQL:
We cannot use some of the SQL statements Dynamically.
Performance of these statements is poor as compared to Static SQL.
Limitations of Static SQL:
They do not change at runtime thus are hard-coded into applications. (GeeksforGeeks ,n.d.)
Differences between Static SQL and Dynamic SQL
Static (Embedded) SQL Dynamic (Interactive) SQL
In Static SQL, how database will be accessed is In Dynamic SQL, how database will be
predetermined in the embedded SQL statement. accessed is determined at run time.
It is swifter and more efficient. It is less swift and efficient.
SQL statements are compiled at compile time. SQL statements are compiled at run time.
Parsing, Validation, Optimization and Parsing, Validation, Optimization and
Generation of application plan are done at Generation of application plan are done at run
compile time. time.
It is generally used for situations where data is It is generally used for situations where data is
distributed uniformly. distributed non uniformly.
EXECUTE IMMEDIATE, EXECUTE and EXECUTE IMMEDIATE, EXECUTE and
PREPARE statements are not used. PREPARE statements are used.
It is less flexible. It is more flexible.
(GeeksforGeeks ,n.d.)
Features and examples:
"Static SQL is the most traditional way of building embedded SQL applications. Static SQL
applications are designed for scenarios where the applications need to issue the same SQL
statements every time it interacts with the database. For example, an application which updates
the inventory stock, would always issue the same SQL statement to add new stock. Similarly, an
online reservation system would always update the same table and mark the same column as