在 SQL 加载程序控制文件中使用 CASE 语句

USING CASE STATEMENT IN SQL LOADER CONTROL FILE

我有一个将文本加载到 oracle 的控制文件,但我正在尝试去除 Phone 号码示例 1-469-428-5920 的前 3 位数字到 469-428-5920,请参阅下面的控件文件。语法应该是什么?

下面一直报错,请帮忙

感谢


options (ERRORS=1000, SKIP=2)
load data 
infile '/clients/vca2/data/API/ADHOC_LOAD/VCA_RP_Hospital_Website_Master_List_VCA.CSV'
replace
into table VCABARK_CDI_DV.RP_HOSPITAL_MASTER_LIST
fields terminated by '|'
OPTIONALLY ENCLOSED BY '"' AND '"'
trailing nullcols
(
    HOSPITAL_EXT_NUMBER, 
    REGION, 
    HOSPITAL_NAME, 
    ADDRESS_1, 
    CITY , 
    STATE, 
    POSTAL_CODE, 
    PHONE "CASE WHEN SUBSTR(:PHONE,1,2) = '1-'  THEN ‘SUBSTR(:PHONE,3)’  ELSE ‘:PHONE’ END",
        RCF_PHONE,
    FAX , 
    EMAIL ,
    WEBSITE_CLASS, 
    DOMAIN, 
    SHORTNAME, 
    PMS, 
    INDICATOR_24_HOUR, 
    CARECLUB, 
    HOME_DELIVERY, 
    APPOINTMENT_CTA, 
    FREE_FIRST_EXAM, 
    AAHA , 
    AAFP_MEMBER, 
    CAT_FRIENDLY,
    FEAR_FREE , 
    LOW_STRESS, E
    VECCS, 
    FACEBOOK_URL, 
    GMB_URL , 
    YELP_URL, 
    BOOK_URL, 
    REQUEST_URL,
        HOURS_OPERATIONS_URL,
    HD_URL_SUBDOMAIN, 
    HD_URL_ORIGINAL, 
    PET_PORTAL_URL, 
    AIS_CLINIC_ID, 
    AIS_TOKEN
 )

你没有说你得到了什么错误,但你应该在你的 case 表达式中有引号 - 弯引号或其他引号。而不是:

PHONE "CASE WHEN SUBSTR(:PHONE,1,2) = '1-'  THEN ‘SUBSTR(:PHONE,3)’  ELSE ‘:PHONE’ END",

使用:

PHONE "CASE WHEN SUBSTR(:PHONE,1,2) = '1-' THEN SUBSTR(:PHONE,3) ELSE :PHONE END",

您也可以只保留最后 12 个:

PHONE "SUBSTR(:PHONE, -12, 12)",