create or replace view hls_document_use_seal_vl as
select t.document_use_seal_id,
         t.document_table,
         t.document_id AS change_req_id,
         t.instruments_types,
         (select v.code_value_name
            from sys_code_values_v v
           where v.code_value = t.instruments_types
             and v.code = 'REPURCHASE_TYPES') as instruments_types_n,
         t.common_seal,
         (select v.code_value_name
            from sys_code_values_v v
           where v.code_value = t.common_seal
             and v.code = 'YES_OR_NO') as common_seal_n,
         t.corporate_visa_seal,
         (select v.code_value_name
            from sys_code_values_v v
           where v.code_value = t.corporate_visa_seal
             and v.code = 'YES_OR_NO') as corporate_visa_seal_n,
         t.legal_seal,
         (select v.code_value_name
            from sys_code_values_v v
           where v.code_value = t.legal_seal
             and v.code = 'YES_OR_NO') as legal_seal_n,
         t.con_special_seal,
         (select v.code_value_name
            from sys_code_values_v v
           where v.code_value = t.con_special_seal
             and v.code = 'YES_OR_NO') as con_special_seal_n,
         t.financial_seal,
         (select v.code_value_name
            from sys_code_values_v v
           where v.code_value = t.financial_seal
             and v.code = 'YES_OR_NO') as financial_seal_n,
         t.supervisio_seal,
         (select v.code_value_name
            from sys_code_values_v v
           where v.code_value = t.supervisio_seal
             and v.code = 'YES_OR_NO') as supervisio_seal_n,
         t.seal_number as SEAL_QUANTITY,
         t.seal_number,
         (select v.code_value_name
            from sys_code_values_v v
           where v.code_value = t.seal_number
             and v.code = 'SEAL_NUMBER'
             and v.code_enabled_flag='Y'
             and v.code_value_enabled_flag='Y')  seal_number_n
    from HLS_DOCUMENT_USE_SEAL t;