--when 'Template Selector' then sKey := '020101';
INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID)
SELECT '020101', MAX(ID_) 
FROM wfs.jbpm_processdefinition 
WHERE NAME_ = 'Template Selector' AND PROCESSDEFINITIONTYPEID=2;

--when 'Purge' then sKey := '020102';
INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID)
SELECT '020102', MAX(ID_) 
FROM wfs.jbpm_processdefinition 
WHERE NAME_ = 'Purge' AND PROCESSDEFINITIONTYPEID=2;

--when 'Adult Asset Arrival Success' then sKey := '060101_ADULT';
INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID)
SELECT '060101_ADULT', MAX(ID_) 
FROM wfs.jbpm_processdefinition 
WHERE NAME_ = 'Adult Asset Arrival Success' AND PROCESSDEFINITIONTYPEID=2;

--when 'Adult Asset Arrival Failure' then sKey := '060102_ADULT';
INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID)
SELECT '060102_ADULT', MAX(ID_) 
FROM wfs.jbpm_processdefinition 
WHERE NAME_ = 'Adult Asset Arrival Failure' AND PROCESSDEFINITIONTYPEID=2;

--when 'Adult Movie SD' then sKey := 'Adult Movie SD Template';
INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID)
SELECT 'Adult Movie SD Template', MAX(ID_) 
FROM wfs.jbpm_processdefinition 
WHERE NAME_ = 'Adult Movie SD' AND PROCESSDEFINITIONTYPEID=2;

--when 'Adult Movie HD' then sKey := 'Adult Movie HD Template';
INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID)
SELECT 'Adult Movie HD Template', MAX(ID_) 
FROM wfs.jbpm_processdefinition 
WHERE NAME_ = 'Adult Movie HD' AND PROCESSDEFINITIONTYPEID=2;

--when 'Adult Poster' then sKey := 'Adult Poster Template';
INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID)
SELECT 'Adult Poster Template', MAX(ID_) 
FROM wfs.jbpm_processdefinition 
WHERE NAME_ = 'Adult Poster' AND PROCESSDEFINITIONTYPEID=2;

--when 'Adult Trailer' then sKey := 'Adult Trailer Template';
INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID)
SELECT 'Adult Trailer Template', MAX(ID_) 
FROM wfs.jbpm_processdefinition 
WHERE NAME_ = 'Adult Trailer' AND PROCESSDEFINITIONTYPEID=2;

/*
--when 'Adult Trailer using XPort' then sKey := 'Adult Trailer Template';
INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID)
SELECT 'Adult Trailer Template', MAX(ID_) 
FROM wfs.jbpm_processdefinition 
WHERE NAME_ = 'Adult Trailer using XPort' AND PROCESSDEFINITIONTYPEID=2;
*/

--when 'Asset Arrival Success' then sKey := '060101_NON-ADULT';
INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID)
SELECT '060101_NON-ADULT', MAX(ID_) 
FROM wfs.jbpm_processdefinition 
WHERE NAME_ = 'Asset Arrival Success' AND PROCESSDEFINITIONTYPEID=2;

--when 'Asset Arrival Failure' then sKey := '060102_NON-ADULT';
INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID)
SELECT '060102_NON-ADULT', MAX(ID_) 
FROM wfs.jbpm_processdefinition 
WHERE NAME_ = 'Asset Arrival Failure' AND PROCESSDEFINITIONTYPEID=2;

--when 'Movie SD' then sKey := 'Non-Adult Movie SD Template';
INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID)
SELECT 'Non-Adult Movie SD Template', MAX(ID_) 
FROM wfs.jbpm_processdefinition 
WHERE NAME_ = 'Movie SD' AND PROCESSDEFINITIONTYPEID=2;

--when 'Movie HD' then sKey := 'Non-Adult Movie HD Template';
INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID)
SELECT 'Non-Adult Movie HD Template', MAX(ID_) 
FROM wfs.jbpm_processdefinition 
WHERE NAME_ = 'Movie HD' AND PROCESSDEFINITIONTYPEID=2;

--when 'Home Page' then sKey := 'Non-Adult HomePage Template';
INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID)
SELECT 'Non-Adult HomePage Template', MAX(ID_) 
FROM wfs.jbpm_processdefinition 
WHERE NAME_ = 'Home Page' AND PROCESSDEFINITIONTYPEID=2;

--when 'Row Ad' then sKey := 'Non-Adult RowAd Template';
INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID)
SELECT 'Non-Adult RowAd Template', MAX(ID_) 
FROM wfs.jbpm_processdefinition 
WHERE NAME_ = 'Row Ad' AND PROCESSDEFINITIONTYPEID=2;

--when 'Trailer' then sKey := 'Non-Adult Trailer Template';
INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID)
SELECT 'Non-Adult Trailer Template', MAX(ID_) 
FROM wfs.jbpm_processdefinition 
WHERE NAME_ = 'Trailer' AND PROCESSDEFINITIONTYPEID=2;

/*
--when 'Trailer using XPort' then sKey := 'Adult Trailer Template';
INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID)
SELECT 'Adult Trailer Template', MAX(ID_) 
FROM wfs.jbpm_processdefinition 
WHERE NAME_ = 'Trailer using XPort' AND PROCESSDEFINITIONTYPEID=2;
*/

--when 'Poster' then sKey := 'Non-Adult Poster Template';
INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID)
SELECT 'Non-Adult Poster Template', MAX(ID_) 
FROM wfs.jbpm_processdefinition 
WHERE NAME_ = 'Poster' AND PROCESSDEFINITIONTYPEID=2;

INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID) SELECT '120101', max(ID_) 
FROM wfs.jbpm_processdefinition  
WHERE NAME_ = 'Asset Arrival Success - Row Ad' AND PROCESSDEFINITIONTYPEID=2;

INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID) 
SELECT '120102', max(ID_) FROM wfs.jbpm_processdefinition  
WHERE NAME_ = 'Asset Arrival Failure' AND PROCESSDEFINITIONTYPEID=2;

INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID) 
SELECT '120103', max(ID_) FROM wfs.jbpm_processdefinition  
WHERE NAME_ = 'Asset Arrival Success - Home Page' AND PROCESSDEFINITIONTYPEID=2;

INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID) 
SELECT '120104', max(ID_) FROM wfs.jbpm_processdefinition  
WHERE NAME_ = 'Adult Asset Arrival Failure' AND PROCESSDEFINITIONTYPEID=2;

INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID) 
SELECT '120105', max(ID_) FROM wfs.jbpm_processdefinition  
WHERE NAME_ = 'Asset Arrival Success - Mobile' AND PROCESSDEFINITIONTYPEID=2;

INSERT INTO wfs.TTV_SELECTOR(SELECTIONKEY,PROCESSDEFINITIONID) 
SELECT 'Non-Adult Mobile Template', max(ID_) FROM wfs.jbpm_processdefinition  
WHERE NAME_ = 'Mobile' AND PROCESSDEFINITIONTYPEID=2;
