SELECT dict_name FROM sys_dictionary WHERE dict_type = 'gateway' and dict_code = beg.gateway_type
這一條作為子查詢時出現syntax error at end of input
錯誤
百度一下是因為參數為空導致的, beg.gateway_type
這個是左連接的右表, 所以的確可能為空.
於是我加了一個判斷, 改為:
CASE WHEN gateway_type is not null THEN (SELECT dict_name FROM sys_dictionary WHERE dict_type = 'gateway' and dict_code = beg.gateway_type) ELSE null END as gateway_typename
就好了