CREATE VIEW QW_DD_TICKETSTATUS_VW AS
SELECT
  qw_enumvalue AS pkey, qw_enumlabel AS value
FROM
  QW_FIELDINFO
WHERE (qw_tablename = 'qw_ticket')
  AND (qw_columnname = 'qw_status')
;

CREATE VIEW QW_DD_TICKETPRIORITY_VW AS
SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
FROM QW_FIELDINFO
WHERE (qw_tablename = 'qw_ticket')
  AND (qw_columnname = 'qw_priority')
;

CREATE VIEW QW_DD_TICKETTYPE_VW AS
SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
FROM QW_FIELDINFO
WHERE (qw_tablename = 'qw_ticket')
  AND (qw_columnname = 'qw_type')
;

CREATE VIEW QW_DD_TICKETSOURCE_VW AS
SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
FROM QW_FIELDINFO
WHERE (qw_tablename = 'qw_ticket')
  AND (qw_columnname = 'qw_source')
;

CREATE VIEW QW_DD_TICKETIMPACT_VW AS
SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
FROM QW_FIELDINFO
WHERE (qw_tablename = 'qw_ticket')
  AND (qw_columnname = 'qw_impact')
;

CREATE VIEW QW_DD_ADDRESSTYPE_VW AS
SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
FROM QW_FIELDINFO
WHERE (qw_tablename = 'qw_address')
  AND (qw_columnname = 'qw_addresstype')
;

CREATE VIEW QW_DD_EMPLOYEEREACHBY_VW AS
SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
FROM QW_FIELDINFO
WHERE (qw_tablename = 'qw_employee')
  AND (qw_columnname = 'qw_reachby')
;

CREATE VIEW QW_DD_TICKETWHYCLOSED_VW AS
SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
FROM QW_FIELDINFO
WHERE (qw_tablename = 'qw_ticket')
  AND (qw_columnname = 'qw_reasoncallid')
;

CREATE VIEW QW_DD_INTERSOURCE_VW AS
SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
FROM QW_FIELDINFO
WHERE (qw_tablename = 'qw_interaction')
  AND (qw_columnname = 'qw_source')
;

CREATE VIEW QW_DD_INTERACTION_VW AS
	SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
	FROM QW_FIELDINFO
	WHERE (qw_tablename = 'qw_interaction')
		AND (qw_columnname = 'qw_action')
;

CREATE VIEW QW_DD_TNSENDMODE_VW AS
	SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
	FROM QW_FIELDINFO
	WHERE (qw_tablename = 'qw_ticketnotification')
		  AND (qw_columnname = 'qw_sendmode')
;

CREATE VIEW QW_DD_NOTIFICATIONSTATUS_VW AS
	SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
	FROM QW_FIELDINFO
	WHERE (qw_tablename = 'qw_ticketnotification_status')
		AND (qw_columnname = 'qw_status')
;

CREATE VIEW QW_DD_NOTIFICATIONPRIORITY_VW AS
	SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
	FROM QW_FIELDINFO
	WHERE (qw_tablename = 'qw_ticketnotification_priority')
		AND (qw_columnname = 'qw_priority')
;

CREATE VIEW QW_DD_NOTIFICATIONRECIPIENT_VW AS
	SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
	FROM QW_FIELDINFO
	WHERE (qw_tablename = 'qw_ticketnotification_recip')
		AND (qw_columnname = 'qw_recipient')
;

CREATE VIEW QW_DD_ESCALATIONSTATUS_VW AS
	SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
	FROM QW_FIELDINFO
	WHERE (qw_tablename = 'qw_ticketescalation_status')
		AND (qw_columnname = 'qw_status')
;

CREATE VIEW QW_DD_ESCALATIONPRIORITY_VW AS
	SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
	FROM QW_FIELDINFO
	WHERE (qw_tablename = 'qw_ticketescalation_priority')
		AND (qw_columnname = 'qw_priority')
;

CREATE VIEW QW_DD_ESCALATIONRECIPIENT_VW AS
	SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
	FROM QW_FIELDINFO
	WHERE (qw_tablename = 'qw_ticketescalation_recipient')
		AND (qw_columnname = 'qw_recipient')
;

CREATE VIEW QW_DD_ESCALATIONFIREIF_VW AS
	SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
	FROM QW_FIELDINFO
	WHERE (qw_tablename = 'qw_ticketescalation')
		  AND (qw_columnname = 'qw_fireif')
;

CREATE VIEW QW_DD_ESCALATIONTIMEUNIT_VW AS
	SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
	FROM QW_FIELDINFO
	WHERE (qw_tablename = 'qw_ticketescalation')
		  AND (qw_columnname = 'qw_timeunit')
;

CREATE VIEW QW_DD_SOLUTIONTOPIC_VW AS
	SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
	FROM QW_FIELDINFO
	WHERE (qw_tablename = 'qw_solution')
		  AND (qw_columnname = 'qw_topic')
;

CREATE VIEW QW_DD_SOLUTIONSTATUS_VW AS
	SELECT qw_enumvalue AS pkey, qw_enumlabel AS value
	FROM QW_FIELDINFO
	WHERE (qw_tablename = 'qw_solution')
		  AND (qw_columnname = 'qw_solutionstatus')
;

CREATE VIEW QW_DD_WORKFLOWOBJECTS_VW AS
SELECT
  qw_enumvalue AS pkey, qw_enumlabel AS value
FROM
  QW_FIELDINFO
WHERE (qw_tablename = 'qw_workflow')
  AND (qw_columnname = 'qw_objecttype')
;

CREATE VIEW QW_DD_WORKFLOWSTATUS_VW AS
SELECT 
  qw_enumvalue AS pkey, qw_enumlabel AS value, 0 AS object
FROM 
  QW_FIELDINFO
WHERE (qw_tablename = 'qw_solution')
  AND (qw_columnname = 'qw_solutionstatus')
UNION ALL
SELECT 
  qw_enumvalue AS pkey, qw_enumlabel AS value, 1
FROM 
  QW_FIELDINFO
WHERE (qw_tablename = 'qw_ticket')
  AND (qw_columnname = 'qw_status')
;
