ORA-932预计日期,得到朱利安日期

时间:2018-01-14 15:32:19

标签: java sql oracle sql-update

所以我有这张桌子:

CREATE TABLE products
(   
    id INTEGER PRIMARY KEY,
    name VARCHAR2(30),
    id_pc INTEGER,
    onStock INTEGER,
    onMarket DATE,
    CONSTRAINT fkProducts FOREIGN KEY (id_pc) REFERENCES producers(id),
    CONSTRAINT ckProducts CHECK (onStock BETWEEN 0 AND 1000)
);

这是我的更新:

public void updateProducts(ArrayList<Product> collProducts) throws Exception{

    String update
            = " UPDATE products "
            + "  SET name = ?, "
            + "  onMarket = onMarket-?,"
            + "  onStock = ?"
            + " WHERE id = ? ";


    PreparedStatement stmt = conn.prepareStatement(update, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);

    for (Product prod : collProducts) {
        stmt.setString(1, prod.getName());
        stmt.setDate(2, Date.valueOf(prod.getOnMarket()));
        stmt.setInt(3, prod.getDecStock());
        prod.setDecStock(0);
        stmt.setInt(4, prod.getId());
        stmt.executeUpdate();           
    }
}

每当我尝试更新产品集合时,都会发生上述命名错误。我的“onMarket”已经是本地日期。但显然我不能把它当作Juliandate的预期。

0 个答案:

没有答案