CREATE PROCEDURE TmSp_Pervasive_Sequence_Creation
LANGUAGE SQLSCRIPT 
SQL SECURITY INVOKER
AS

BEGIN

/* If SEQUENCE exists, do nothing */
DECLARE EXIST_SEQ INT;
SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'OKPI_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE OKPI_S INCREMENT BY 1 START WITH 1';
END IF;

SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'KPI1_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE KPI1_S INCREMENT BY 1 START WITH 1';
END IF;

SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'KPI2_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE KPI2_S INCREMENT BY 1 START WITH 1';
END IF;

SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'KPI3_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE KPI3_S INCREMENT BY 1 START WITH 1';
END IF;

SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'KPI4_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE KPI4_S INCREMENT BY 1 START WITH 1';
END IF;

SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'KPI5_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE KPI5_S INCREMENT BY 1 START WITH 1';
END IF;

SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'PACT_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE PACT_S INCREMENT BY 1 START WITH 1';
END IF;

SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'PACT1_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE PACT1_S INCREMENT BY 1 START WITH 1';
END IF;

SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'PACT3_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE PACT3_S INCREMENT BY 1 START WITH 1';
END IF;

SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'OWPK_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE OWPK_S INCREMENT BY 1 START WITH 10000';
END IF;

SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'WPK3_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE WPK3_S INCREMENT BY 1 START WITH 10000';
END IF;

SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'WPK4_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE WPK4_S INCREMENT BY 1 START WITH 10000';
END IF;

SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'P_WPK1_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE P_WPK1_S INCREMENT BY 1 START WITH 1';
END IF;

SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'P_WPK2_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE P_WPK2_S INCREMENT BY 1 START WITH 1';
END IF;

SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'OXAP_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE OXAP_S INCREMENT BY 1 START WITH 10000';
END IF;

SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'XAP1_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE XAP1_S INCREMENT BY 1 START WITH 10000';
END IF;

SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'XAP2_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE XAP2_S INCREMENT BY 1 START WITH 10000';
END IF;

SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'XAP3_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE XAP3_S INCREMENT BY 1 START WITH 10000';
END IF;

SELECT COUNT(*) INTO EXIST_SEQ FROM "PUBLIC".SEQUENCES WHERE SEQUENCE_NAME = 'XAP4_S' AND SCHEMA_NAME = CURRENT_SCHEMA; 
IF EXIST_SEQ = 0 THEN 
	/* Create SEQUENCE. */
	EXEC 'CREATE SEQUENCE XAP4_S INCREMENT BY 1 START WITH 10000';
END IF;
END;