1

我正在使用 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 服务器,但没有奏效。

如何从iOS本机应用程序将DATE格式发送到sales_order表格到列?order_date

感谢你的帮助。

4

1 回答 1

0

sybase 文档在这里说

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

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

你能试试这些选项之一吗?

于 2014-03-03T16:20:10.423 回答