DB2 10.5 for Linux, UNIX, and Windows

Saving SQL requests from end users

If the users of your application can issue SQL requests from the application, you might want to save these requests.

About this task

If your application allows users to save arbitrary SQL statements, you can save them in a table with a column having a data type of VARCHAR, CLOB, VARGRAPHIC or DBCLOB. Note that the VARGRAPHIC and DBCLOB data types are only available in double-byte character set (DBCS) and Extended UNIX Code (EUC) environments.

You must save the source SQL statements, not the prepared versions. This means that you must retrieve and then prepare each statement before executing the version stored in the table. In essence, your application prepares an SQL statement from a character string and executes this statement dynamically.