DELIMITER //

-- use qwoss
-- //

SET storage_engine=InnoDB
//


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_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_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_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')
//
