在此,我們要建立具有Enumerations類型計算欄位的查詢。 此欄位將在資料預覽視窗中產生其他欄。 此欄會指定每個收件者(0、1和2)的結果傳回的數值。 新欄中的每個值都會指派性別:「男性」代表「1」,「女性」代表「2」,或「未指出」(如果值等於「0」)。
需要選擇哪個表?
收件者表(nms:recipient)
要在輸出欄中選取的欄位?
姓氏、名字、性別
要根據哪些標準篩選資訊?
收件者語言
應用以下步驟:
開啟「一般查詢編輯器」並選取「收件者」表格(nms:recipient)。
在Data to extract窗口中,選擇Last name、First name和Gender。
在Sorting視窗中,按一下Next:此示例不需要排序。
在 Data filtering 中選取 Filtering conditions。
在Target element視窗中,設定篩選條件以收集會說英語的收件者。
在Data formatting窗口中,按一下Add a calculated field。
轉到Export calculated field definition窗口的Type窗口,然後選擇Enumerations。
定義新計算欄位必須引用的列。 若要這麼做,請在Source column欄位的下拉式選單中選取Gender欄:目標值與Gender列一致。
定義Source和Destination值:目標值使查詢結果更易於讀取。 此查詢應返回收件者性別,結果為0、1或2。
對於要輸入的每行"source-destination",按一下List of enumeration values中的Add :
選擇Keep the source value函式。
按一下OK以核准計算欄位。
在Data formatting窗口中,按一下Next。
在預覽窗口中, start the preview of the data。
附加一欄定義0、1和2的性別:
例如,如果您未在List of enumeration values中輸入性別"2",而且已選取In other cases欄位的Generate a warning and continue函式,則會收到警告記錄。 此日誌表示未輸入性別"2"(女性)。 它顯示在資料預覽視窗的Logs generated during export欄位中。
讓我們舉另一個例子,說明未輸入枚舉值"2"。 選擇Generate an error and reject the line函式:所有性別"2"的收件者都會引發異常,以及行中的其他資訊(名字和姓氏等) 將不導出。 在資料預覽窗口的Logs generated during export欄位中顯示錯誤日誌。 此日誌表示未輸入枚舉值"2"。