Acquiring additional storage

If your routine expands the SQL statements beyond the length specified in the 2-byte SQL length field, the parse exit routine must acquire additional storage before it alters the SQL text.

WARNING! A storage violation can occur if your routine expands the SQL text area beyond the specified length in the 2-byte SQL length field without first acquiring additional storage.

To acquire additional storage for a larger SQL text area, your routine must issue a GETMAIN command. Like the old SQL text area, the new one must allow 2 bytes for the length field in addition to the area needed for the expanded SQL statement.

After altering the new SQL text, your routine must:

This pointer should be altered by the parse exit routine to hold the new address of the SQL text area if this address is changed by the exit routine. It is only necessary to acquire a new SQL text area if the existing area is not large enough for the SQL text after it is altered by the user.

Your exit routine does not need to deallocate the storage it acquires. After the routine returns, AMD2 checks the SQL text pointer. If the pointer changed during the exit routine execution, AMD2 deallocates the additional storage after DB2 UDB processes the SQL statement.