Oracle阻止从Kendo数据源发送日期格式

Oracle阻止从Kendo数据源发送日期格式,oracle,kendo-ui,kendo-grid,odata,kendo-datasource,Oracle,Kendo Ui,Kendo Grid,Odata,Kendo Datasource,我有一个数据源,它将Odata传递给TEID,然后再传递给Oracle。然而,当我试图从剑道数据源向Oracle传递一个日期时,Oracle感到窒息。我认为这是因为Oracle不承认它发送的格式的日期字符串有效,例如,2014-07-01T05:00:00.000Z。下面是我得到的错误: avax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.4.1.v2

我有一个数据源,它将Odata传递给TEID,然后再传递给Oracle。然而,当我试图从剑道数据源向Oracle传递一个日期时,Oracle感到窒息。我认为这是因为Oracle不承认它发送的格式的日期字符串有效,例如,2014-07-01T05:00:00.000Z。下面是我得到的错误:

avax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.teiid.jdbc.TeiidSQLException: TEIID30504 JTRAC_DEV_ENV: 1843 TEIID11013:TEIID11004 Error executing statement(s): [Prepared Values: ['2014-07-01T05:00:00.000Z', 700281, 700280] SQL: UPDATE "JTRAC"."MAPPED_HISTORY" SET "TIME_STAMP" = ? WHERE "JTRAC"."MAPPED_HISTORY"."HISTORY_ID" = ? AND "JTRAC"."MAPPED_HISTORY"."ITEM_ID" = ?]
Error Code: 1843
Call: UPDATE "JTRAC.MAPPED_HISTORY" SET "TIME_STAMP" = ? WHERE ((("HISTORY_ID" = ?) AND ("ITEM_ID" = ?)) AND ("TEIID_MULTI_DATA_SOURCE_COLUMN" = ?))
bind => [2014-07-01T05:00:00.000Z, 700281, 700280, JTRAC_DEV_ENV]
如何将时间戳更改为可以工作的内容?我尝试用parameterMap(到那个阶段还没有转换它-仍然是相当正常的时间格式)、requestStart(我似乎无法访问数据来篡改它)和parse(没有按我预期的方式工作)截取它。作为记录,另一端有一个INSTEAD OF Oracle触发器,因为最终我要更新一个视图。想法

这是我使用的触发器:

create or replace 
trigger update_mapped_history
  INSTEAD OF UPDATE ON mapped_history
  FOR EACH ROW
DECLARE
  new_status_id number;
  new_assigned_to number;
  new_logged_by number;
  new_timestamp timestamp;
  cmmd VARCHAR2(100);
BEGIN
  cmmd:='alter session set NLS_TIMESTAMP_FORMAT=''YYYY-MM-DD"T"HH:MI:SS.FF"Z"''';
  EXECUTE IMMEDIATE cmmd;
  SELECT status_id INTO new_status_id FROM status_int_mapping WHERE status_label=:NEW.status AND space_id = (select i.space_id from items i where i.id = :OLD.item_id);
  SELECT id INTO new_assigned_to FROM users WHERE login_name = :NEW.assigned_to;
  SELECT id INTO new_logged_by FROM users WHERE login_name = :NEW.logged_by;
  select FROM_TZ(TO_TIMESTAMP(:NEW.time_stamp, 'YYYY-MM-DD"T"HH:MI:SS.FF"Z"'),'UTC') at time zone 'US/Central' into new_timestamp from dual;
  UPDATE history SET
    logged_by = new_logged_by, 
    status = new_status_id,
    assigned_to = new_assigned_to,
    jt_comment = :NEW.jt_comment,
    time_stamp = new_timestamp
  WHERE id=:OLD.history_id;
END;
这是我荣耀的代码

historyDataSource = new kendo.data.DataSource({
        //autoSync: true,
        type: "odata",
        serverFiltering: true,
        serverPaging: true,
        serverSorting: true,
        pageSize: 10,
        transport: {
            read: {
                url: baseUrl + "MAPPED_HISTORY",
                type: "GET",
                headers: {
                    Authorization: authorizationStr64
                },
                dataType: "json"
            },
            update: {
                url: function(options){
                    return kendo.format(baseUrl + "MAPPED_HISTORY"+"({0})", options.HISTORY_ID);
                },
                type: "PUT",
                headers: {
                    Authorization: authorizationStr64
                },
                dataType: "json",
                contentType: "application/json"
            },
            create: {
                url: baseUrl + "MAPPED_HISTORY",
                type: "POST",
                headers: {
                    Authorization: authorizationStr64
                },
                dataType: "json"
            },
            destroy: {
                //url: "http://amr-dsiprod05:8080/odata/SDA/TEIID_TEST",
                url: function(options){
                    return kendo.format(baseUrl + "MAPPED_HISTORY"+"({0})", options.HISTORY_ID);
                },
                type: "DELETE",
                headers: {
                    Authorization: authorizationStr64
                },
                dataType: "json"
            },
            parameterMap: function(data,type){
                if(type=='update'){
                    debugger;
                }
                return data;
            }
        },
        // Enable server filtering so we don't have to download the whole history data set
        serverFiltering: true,
        filter: { logic: "and", filters: [ { field: "HISTORY_ID", operator: "equals", value: historyId } ] },

        "schema": {
            "model": {
                "id": "HISTORY_ID",
                "fields": {
                    /*"HISTORY_ID": {
                        "editable": true,
                        "nullable": false
                    },
                    "ITEM_ID": {
                        "editable": true,
                        "nullable": true
                    },*/
                    "LOGGED_BY": {
                        "editable": false,
                        "nullable": true
                    },
                    "STATUS": {
                        "editable": false,
                        "nullable": false
                    },
                    "ASSIGNED_TO": {
                        "editable": false,
                        "nullable": true
                    },
                    "JT_COMMENT": {
                        "editable": true,
                        "nullable": true
                    },
                    "TIME_STAMP": {
                        "editable": true,
                        "nullable": false
                    }
                }
            },
            errors: "error"/*,
            parse:function (response) {
                $.each(response, function (idx, elem) {
                    if (elem.Date && typeof elem.Date === "string") {
                        elem.Date = kendo.parseDate(elem.Date, "yyyy-MM-ddTHH:mm:ss.fffZ");
                        console.log(elem.Date);
                        debugger;
                    }
                });
                return response;
            }*/
        },
        error: function(e){
            if(confirm("Could not update or display data! Show full error report?")){
                var myWindow = window.open("", "MsgWindow", "width=1000, height=800,resizable=yes, ");
                myWindow.document.write(e.xhr.responseText);
            }
            //console.log();
        },
        /*requestStart: function(e){
            if(e.type=='update'){
                debugger;
            }
        },
        requestEnd: function(e){
            if(e.type=='update'){
                debugger;
                for(var i=0; i<e.response.d.results.length; i++){  
                    var timeStamp = kendo.parseDate(e.response.d.results[i].time_stamp);
                    var utcTimeStamp = new Date(timeStamp.getTime() + timeStamp.getTimezoneOffset() * 60000);
                    e.response.d.results[i].OrderDate = utcTimeStamp;
                    alert(utcTimeStamp);
                }
                debugger;//alert('updating kendo!');
            }
        }*/
    });   
    historyDataSource.read();


    $("#" + divId).kendoGrid({
        "dataSource": historyDataSource,
        "autoBind": false,
        "pageable": true,
        "height": 350,
        "selectable": true,
        "editable": true,
        "toolbar": [/*"create",*/"save","cancel"],
        "columns": [
            //{ "field": "HISTORY_ID", "width":"100px" },
            //{ "field": "ITEM_ID", "width":"100px" },
            { "field": "LOGGED_BY", "width":"160px", editor: usersDropDownEditor, template: "#=LOGGED_BY#"  },
            { "field": "STATUS", "width":"200px" , editor: statusDropDownEditor, template: "#=STATUS#"  },
            { "field": "ASSIGNED_TO", "width":"160px", editor: usersDropDownEditor, template: "#=ASSIGNED_TO#"  },
            { "field": "JT_COMMENT"},
            { "field": "TIME_STAMP", "width":"200px", format: "{0:MM/dd/yyyy hh:mm tt}", editor: dateTimeEditor }//,
            //{ "command": "destroy" }
        ]
    });

    function dateTimeEditor(container, options) {
        $('<input data-text-field="' + options.field + '" data-value-field="' + options.field + '" data-bind="value:' + options.field + '" data-format="' + options.format + '"/>')
                .appendTo(container)
                .kendoDateTimePicker({
                    interval: 05,
                    min: new Date(2011, 0, 1),
                    timeFormat: "HH:mm"
                    /*parseFormats: ["yyyy-MM-dd hh:mm:ss"]*/
                });
    }

    function statusDropDownEditor(container, options) {
        var statusInput = $('<input required data-text-field="STATUS_LABEL" data-value-field="STATUS_LABEL" data-bind="value:' + options.field + '"/>')
            .appendTo(container)
            .kendoDropDownList({
                autoBind: false,
                dataSource: {
                    type: "odata",
                    transport: {
                        read: {
                            url: baseUrl + "STATUS_INT_MAPPING",
                            type: "GET",
                            headers: {
                                Authorization: authorizationStr64
                            },
                            dataType: "json"
                        }
                    },
                    serverFiltering: true,
                    filter: { logic: "and", filters: [ {field: "SPACE_ID", operator: "equals", value: spaceId}]}
                }
            });
    }

    function usersDropDownEditor(container, options) {
        var usersInput= $('<input required data-text-field="LOGIN_NAME" data-value-field="LOGIN_NAME" data-bind="value:' + options.field + '"/>')
            .appendTo(container)
            .kendoDropDownList({
                autoBind: false,
                dataSource: {
                    type: "odata",
                    transport: {
                        read: {
                            url: baseUrl + "SPACE_LOGIN_NAMES",
                            type: "GET",
                            headers: {
                                Authorization: authorizationStr64
                            },
                            dataType: "json"
                        }
                    },
                    serverFiltering: true,
                    filter: { logic: "and", filters: [ {field: "SPACE_ID", operator: "equals", value: spaceId}]}
                }
            });
    }
});
historyDataSource=new kendo.data.DataSource({
//自动同步:对,
类型:“odata”,
是的,
对,,
对,,
页面大小:10,
运输:{
阅读:{
url:baseUrl+“映射的历史”,
键入:“获取”,
标题:{
授权:授权STR64
},
数据类型:“json”
},
更新:{
url:函数(选项){
返回kendo.format(baseUrl+“MAPPED_HISTORY”+“({0})”,options.HISTORY_ID);
},
键入:“放置”,
标题:{
授权:授权STR64
},
数据类型:“json”,
contentType:“应用程序/json”
},
创建:{
url:baseUrl+“映射的历史”,
类型:“POST”,
标题:{
授权:授权STR64
},
数据类型:“json”
},
销毁:{
//url:“http://amr-dsiprod05:8080/odata/SDA/TEIID_TEST",
url:函数(选项){
返回kendo.format(baseUrl+“MAPPED_HISTORY”+“({0})”,options.HISTORY_ID);
},
键入:“删除”,
标题:{
授权:授权STR64
},
数据类型:“json”
},
parameterMap:函数(数据,类型){
如果(类型=='update'){
调试器;
}
返回数据;
}
},
//启用服务器筛选,这样我们就不必下载整个历史数据集
是的,
过滤器:{logic:“and”,过滤器:[{field:“HISTORY_ID”,运算符:“equals”,值:historyId}]},
“模式”:{
“模型”:{
“id”:“历史号”,
“字段”:{
/*“历史号”:{
“可编辑”:真,
“可为空”:false
},
“项目ID”:{
“可编辑”:真,
“可为空”:真
},*/
“记录者”:{
“可编辑”:false,
“可为空”:真
},
“地位”:{
“可编辑”:false,
“可为空”:false
},
“分配给”:{
“可编辑”:false,
“可为空”:真
},
“JT_评论”:{
“可编辑”:真,
“可为空”:真
},
“时间戳”:{
“可编辑”:真,
“可为空”:false
}
}
},
错误:“错误”/*,
解析:函数(响应){
$.each(响应、函数(idx、元素){
if(elem.Date&&typeof elem.Date==“string”){
elem.Date=kendo.parseDate(elem.Date,“yyyy-MM-ddTHH:MM:ss.fffZ”);
控制台日志(要素日期);
调试器;
}
});
返回响应;
}*/
},
错误:函数(e){
如果(确认(“无法更新或显示数据!显示完整错误报告?”){
var myWindow=window.open(“,”MsgWindow“,”宽度=1000,高度=800,可调整大小=yes“);
myWindow.document.write(e.xhr.responseText);
}
//console.log();
},
/*请求启动:函数(e){
如果(e.type=='update'){
调试器;
}
},
requestEnd:函数(e){
如果(e.type=='update'){
调试器;

对于(var i=0;i使用显式
TO_TIMESTAMP()
函数,或在客户端中设置NLS_TIMESTAMP_格式

更多信息可在此处找到:

TO_TIMESTAMP()函数

NLS_时间戳_格式

我尝试在写入视图的INSTEAD Oracle触发器中使用时间戳。唯一的问题是,当它看到预期的时间戳值不是时间戳时,我认为它退出了。如果它更进一步,它会成功地将其转换。你认为NLS\U TIMESTAMP\u格式会绕过这一点吗?好吧,想法是你应该始终使用指定的格式字符串将字符串显式转换为时间戳。方法是使用to_TIMESTAMP()函数。如果失败,Oracle将使用NLS_TIMESTAMP_格式中指定的格式字符串进行隐式转换。因此,如果放弃使用to_TIMESTAMP(),则是的,然后在NLS_TIMESTAMP_格式中设置正确的格式字符串应该可以解决您的问题