SQL DYNAMIC SQL
SQL DYNAMIC SQL
DB2 DYNAMIC SQL : PREPARE and EXECUTE
If you need to run the same dynamic SQL statement more than once per job use the PREPARE – EXECUTE statements using EXECUTE IMMEDIATE incurs the unnecessary cost of re-preparing the SQL statementĀ each time PREPARE is likeĀ a mini-compile of its own. If required info to PREPARE a statement is not available on COMPILE TIME than the [...]
SQL DYNAMIC SQL
DB2 DYNAMIC SQL : EXECUTE IMMEDIATE
EXECUTE IMMEDIATE is simple option to execute a Dynamic SQL. Here is an example TableName = 'CUSTOMER'; SQLString = 'DELETE FROM '+ %TRIM(TableName) ; EXECUTE IMMEDIATE : SQLString
SQL DYNAMIC SQL
DB2 DYNAMIC SQL : BASIC
There are two ways to write SQL one is Static SQL which get job done in most case and second one is Dynamic SQL for rest of complex stuff.
DOWNLOADS