【问题标题】:SUP error while sending date parameter to server向服务器发送日期参数时出现 SUP 错误
【发布时间】:2014-03-03 07:04:59
【问题描述】:

我正在使用 Sybase Unwired Platform 2.1.3 开发 iOS 应用程序,将date 参数发送到数据库时出现错误。

这是我的代码,

@try 
{
    SUP105Sales_order *insertRow =[[SUP105Sales_order alloc]init];
    int32_t idValue =2671;
    int32_t custID =103;
    int32_t sales =506;

    insertRow.id_=idValue;
    insertRow.cust_id=custID;
    insertRow.order_date=[NSDate date];
    insertRow.fin_code_id=@"r1";
    insertRow.region=@"Hyd";
    insertRow.sales_rep=sales;

    [insertRow save];
    [insertRow submitPending];
    [SUP105SUP105DB synchronize];
}
@catch (NSException *exception) {
   NSLog(@"Exception---%@",exception.description);
}

服务器日志,

2014-02-28 16:39:41.833 WARN Other Thread-182 [SUP105.server.SUP105DB]{"_op":"C","level":5,"code":412,"eisCode":"257","message":"com.sybase.jdbc3.jdbc.SybSQLException:SQL Anywhere Error -157: Cannot convert '' to a timestamp","component":"Sales_order","entityKey":"3210004","operation":"create","requestId":"3210005","timestamp":"2014-02-28 11:09:41.646","messageId":0,"_rc":0}

我认为上面的错误是由于日期格式。我尝试了几种其他方式将日期发送到 Sup 服务器,但没有成功。

如何将DATE 格式从iOS 原生应用发送到sales_order 表到order_date 列?

感谢您的帮助。

【问题讨论】:

    标签: ios objective-c sup smp


    【解决方案1】:

    sybase 文档说here

    您不能将数据插入时间戳列。您必须通过在列中键入“NULL”来插入显式空值,或者通过提供跳过时间戳列的列列表来使用隐式空值。 Adaptive Server 在每次插入或更新后更新时间戳值。有关详细信息,请参阅“将数据插入特定列”。

    在您的情况下,您的应用发送的值似乎是一个空字符串“”,时间戳字段不允许这样做。您可以跳过插入请求中的列或将其设置为“NULL”。

    你能试试这些选项吗?

    【讨论】:

    • 我已经尝试过你所说的......但没有结果......我认为我没有将正确的日期格式发送到 sales_order 表中的日期数据类型。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-13
    • 2022-11-07
    • 2016-06-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多