Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kingharrison/68cc58243804e823f1de63cc185c31a1 to your computer and use it in GitHub Desktop.
Save kingharrison/68cc58243804e823f1de63cc185c31a1 to your computer and use it in GitHub Desktop.
IF (NOT EXISTS(SELECT * FROM QSYS2.SYSTABLES WHERE TABLE_SCHEMA = 'BACKUP' AND TABLE_NAME='MYTABLE')) THEN
CREATE TABLE BACKUP.MYTABLE
AS (SELECT * FROM MYLIB.MYTABLE)
WITH DATA;
ELSE
INSERT INTO BACKUP.MYTABLE
SELECT * FROM MYLIB.MYTABLE;
END IF;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment