Testing if temp table exists in iSeries SQL stored procedure What would be the syntax for testing if there is already a global temporary table in DB2 for IBM i 7.1?

I tried this after DECLARE GLOBAL TEMPORARY TABLE:

SELECT * FROM QSYS2.SYSTABLES WHERE SYSTEM_TABLE_SCHEMA = 'QTEMP';


and it returned an empty result set. The permanent tables seem to be included into that view, but not the temporary tables.

Ultimately I need to conditionally drop a temp table or truncate/delete data if it exists.
Add WITH REPLACE to the end of your DECLARE GLOBAL TEMPORARY TABLE statement.  This will create your table in QTEMP regardless of whether one already exists or not.