甚至可以在VBA中运行我的SQLLDR文件吗?

时间:2018-08-10 08:49:08

标签: sql sql-server excel vba

这是我的处境。 我一直在使用SQL将文本文件转换为excel。但是,我的公司不再支持我使用SQL Loader。在失去访问权限之前,我已经下载了SQL控制文件。现在,我必须找到一种无需链接到SQL即可在excel中运行控制文件的方法。

请在下面找到我从SQL导出的SQL文件。有没有办法让我使用VBA在Excel中运行此程序,而无需连接到我再也无法访问的SQL Server?

一直在寻找解决方案,但似乎我的情况很少发生。

LOAD DATAINFILE          'DOC2'  -- Supplied by command line parameter DATA
BADFILE         'DOC2'  -- Supplied by command line parameter BAD
DISCARDFILE     'DOC2'  -- Supplied by command line parameter DISCARD
TRUNCATE
INTO TABLE sqlldr_prfma_route_gen_info
WHEN rec_type = '00'
TRAILING NULLCOLS
(
load_seq_no                                     "-1",
rec_no              POSITION(1:5)       CHAR    "TO_NUMBER(:rec_no)",
rec_type            POSITION(6:7)       CHAR    ,
prfma_date          POSITION(8:17)      CHAR    "TO_DATE(:prfma_date, 'YYYY/MM/DD')",
flt_period          POSITION(18:23)     CHAR    "TO_DATE(:flt_period, 'YYYYMM')",
prfma_ref           POSITION(24:44)     CHAR    ,
curr                POSITION(45:47)     CHAR    ,
ttl_exempted_amt    POSITION(48:60)     CHAR    "TO_NUMBER(LTRIM(REPLACE(SUBSTR(:ttl_exempted_amt,1,10),'.',''))) +
                                                 TO_NUMBER(SUBSTR(:ttl_exempted_amt,12,2)) * 0.01",
ttl_route_chrg_amt  POSITION(61:73)     CHAR    "TO_NUMBER(LTRIM(REPLACE(SUBSTR(:ttl_route_chrg_amt,1,10),'.',''))) +
                                                 TO_NUMBER(SUBSTR(:ttl_route_chrg_amt,12,2)) * 0.01",
user_code_name      POSITION(74:97)     CHAR    "RTRIM(:user_code_name)",
user_billing_addr_1 POSITION(98:137)    CHAR    "RTRIM(:user_billing_addr_1)",
user_billing_addr_2 POSITION(138:177)   CHAR    "RTRIM(:user_billing_addr_2)",
user_billing_addr_3 POSITION(178:217)   CHAR    "RTRIM(:user_billing_addr_3)",
user_billing_addr_4 POSITION(218:257)   CHAR    "RTRIM(:user_billing_addr_4)",
user_billing_addr_5 POSITION(258:297)   CHAR    "RTRIM(:user_billing_addr_5)",
user_billing_addr_6 POSITION(298:337)   CHAR    "RTRIM(:user_billing_addr_6)",
user_billing_addr_7 POSITION(338:377)   CHAR    "RTRIM(:user_billing_addr_7)"
)
INTO TABLE sqlldr_prfma_route_line
WHEN rec_type = '01'
TRAILING NULLCOLS
(
load_seq_no                                     "anscir.seq_ansc_sqlldr.NEXTVAL",
rec_no              POSITION(1:5)       CHAR    "TO_NUMBER(:rec_no)",
rec_type            POSITION(6:7)       CHAR    ,
date_of_flt         POSITION(8:17)      CHAR    "TO_DATE(:date_of_flt, 'YYYY/MM/DD')",
prfma_line_no       POSITION(18:23)     CHAR    "TO_NUMBER(:prfma_line_no)",
flt_no_reg          POSITION(24:32)     CHAR    "RTRIM(:flt_no_reg)",
dep_time            POSITION(33:36)     CHAR    ,
dep_aerodrome       POSITION(37:40)     CHAR    ,
arr_aerodrome       POSITION(41:44)     CHAR    ,
basic_type_of_acft  POSITION(45:51)     CHAR    "RTRIM(:basic_type_of_acft)",
exempt_corr_cd      POSITION(52:52)     CHAR    "RTRIM(:exempt_corr_cd)",
exempt_amt          POSITION(53:62)     CHAR    "TO_NUMBER(LTRIM(REPLACE(SUBSTR(:exempt_amt,1,7),'.',''))) +
                                                 TO_NUMBER(SUBSTR(:exempt_amt,9,2)) * 0.01",
route_chrg_amt      POSITION(63:72)     CHAR    "TO_NUMBER(LTRIM(REPLACE(SUBSTR(:route_chrg_amt,1,7),'.',''))) +
                                                 TO_NUMBER(SUBSTR(:route_chrg_amt,9,2)) * 0.01",
msg_origin_cd       POSITION(73:73)     CHAR    "TO_NUMBER(:msg_origin_cd)",
origin_of_msg       POSITION(74:75)     CHAR    ,
batch_seq_no        POSITION(76:79)     CHAR    "TO_NUMBER(:batch_seq_no)",
weight_coeff        POSITION(80:83)     CHAR    "TO_NUMBER(SUBSTR(:weight_coeff,1,1)) +
                                                 TO_NUMBER(SUBSTR(:weight_coeff,3,2)) * 0.01",
prfma_no            POSITION(84:85)     CHAR    "TO_NUMBER(:prfma_no)",
ifpl_id             POSITION(86:95)     CHAR    ,
rel_prfma_line_no   POSITION(96:101)    CHAR    "TO_NUMBER(:rel_prfma_line_no)",
acft_reg            POSITION(111:114)   CHAR    "RTRIM(:acft_reg)"
)
INTO TABLE sqlldr_prfma_route_chrg
WHEN rec_type = '02'
TRAILING NULLCOLS
(
load_seq_no                                     "anscir.seq_ansc_sqlldr.CURRVAL",
rec_no              POSITION(1:5)       CHAR    "TO_NUMBER(:rec_no)",
rec_type            POSITION(6:7)       CHAR    ,
chrg_area_cd        POSITION(39:40)     CHAR    ,  -- By Edan (28-Apr-09) for CRCO*Datalink version 5.00
vat_amt             POSITION(10:16)     CHAR    "TO_NUMBER(SUBSTR(:vat_amt,1,4)) +
                                                 TO_NUMBER(SUBSTR(:vat_amt,6,2)) * 0.01",
distance_coeff      POSITION(17:21)     CHAR    "TO_NUMBER(SUBSTR(:distance_coeff,1,2)) +
                                                 TO_NUMBER(SUBSTR(:distance_coeff,4,2)) * 0.01",
route_chrg          POSITION(22:28)     CHAR    "TO_NUMBER(SUBSTR(:route_chrg,1,4)) +
                                                 TO_NUMBER(SUBSTR(:route_chrg,6,2)) * 0.01",
chrg_indicator      POSITION(29:29)     CHAR    "TO_NUMBER(:chrg_indicator)"
)
INTO TABLE sqlldr_prfma_route_rso  -- obsolete from CROC*Datalink version 5.00
WHEN rec_type = '03'
TRAILING NULLCOLS
(
load_seq_no                                     "anscir.seq_ansc_sqlldr.CURRVAL",
rec_no              POSITION(1:5)       CHAR    "TO_NUMBER(:rec_no)",
rec_type            POSITION(6:7)       CHAR    ,
rso_route_seq_no    POSITION(8:10)      CHAR    "TO_NUMBER(:rso_route_seq_no)",
route_pt_cd         POSITION(11:14)     CHAR    "RTRIM(:route_pt_cd)",
route_pt_coord      POSITION(15:29)     CHAR    ,
from_chrg_area_cd   POSITION(30:31)     CHAR    ,
to_chrg_area_cd     POSITION(32:33)     CHAR    , 
distance_billed     POSITION(34:37)     CHAR    "TO_NUMBER(:distance_billed)"
)

0 个答案:

没有答案