Saving SQL statements that are translated from user requests

If your program translates requests from users into SQL statements and allows users to save their requests, your program can improve performance by saving those translated statements.

About this task

A program translates requests from users into SQL statements before executing them, and users can save a request.

Procedure

To save the corresponding SQL statement:

Save the corresponding SQL statements in a table with a column having a data type of VARCHAR(n), where n is the maximum length of any SQL statement. You must save the source SQL statements, not the prepared versions. That means that you must retrieve and then prepare each statement before executing the version stored in the table. In essence, your program prepares an SQL statement from a character string and executes it dynamically.