【问题标题】:Oracle column with Timestamp(6) data type extract using ssis使用 ssis 提取 Timestamp(6) 数据类型的 Oracle 列
【发布时间】:2019-03-01 18:55:15
【问题描述】:

我正在尝试使用 SSIS 将 oracle 表数据拉入 sql server。我有一个包变量,其中包含需要在 oracle db 中触发的源查询。我有一个带有 oledb 源(oracle)和 oledb 目标(sql server)的数据流任务。

oledb源码查询(变量)如下

Select A,B,C 
  From "Table" TT  
 Where C in (Select coalesce(ab,cd) as c 
               From "Table" T2 
              Where Last_Upd_Dt >= '2018-09-24 12:00:00')

Last_Upd_Dt 列是 TimeStamp(6),在源 oracle DB 中默认值为 LocalTimeStamp

我的问题是我的输入参数值应该采用什么格式,这样我就不必将Last_Upd_Dt 列转换为TO_DATE()、TO_CHAR() 等。

如果我使用 SSIS 运行该查询,我会得到 ​​p>

ORA-01843:月份无效

【问题讨论】:

    标签: sql oracle oracle11g ssis timestamp


    【解决方案1】:

    随便用

    ... Where Last_Upd_Dt >= to_date('2018-09-24 12:00:00','yyyy-mm-dd hh24:mi:ss')
    

    或

    ... Where Last_Upd_Dt >= timestamp'2018-09-24 12:00:00'
    

    您可以参考以下演示:

    SQL> create table tab ( id int not null, time timestamp(6) default LocalTimeStamp not null );
    
    Table created
    
    SQL> insert into tab(id) values(1);
    
    1 row inserted
    
    SQL> select * from tab t;
    
    ID TIME
    -- --------------------------
     1 26/09/2018 08:23:23,068025
    
    
    SQL> select * from tab where Last_Upd_Dt >= to_date('2018-09-24 12:00:00','yyyy-mm-dd hh24:mi:ss');
    
    ID TIME
    -- --------------------------
     1 26/09/2018 08:23:23,068025
    
    SQL> select * from tab where Last_Upd_Dt >= timestamp'2018-09-24 12:00:00';
    
    ID TIME
    -- --------------------------
     1 26/09/2018 08:23:23,068025
    
    
    SQL> select * from tab where Last_Upd_Dt >= to_date('2018-09-26 12:00:00','yyyy-mm-dd hh24:mi:ss');
    
    ID TIME
    -- --------------------------   
                                  --> no rows selected
    

    【讨论】:

      【解决方案2】:

      Oracle supports DATE 和 TIMESTAMP 关键字。您可以将逻辑表示为:

      where Last_Upd_Dt >= TIMESTAMP '2018-09-24 12:00:00'
      

      如果你没有时间组件,你会这样做:

      where Last_Upd_Dt >= DATE '2018-09-24'
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-03-06
        • 2012-04-03
        • 2011-02-21
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多