【发布时间】:2016-01-14 11:25:57
【问题描述】:
我在postgresql中创建了一个存储过程,如下:
INSERT INTO ABC
(order_id,order_dt, customer_id, route_id, routenum, ordertype, create_station_id, create_stationtype, create_time,create_user_id,tran_time, tran_user_id,station_id)
values
(1,$1, $2, $3, $4, $5, $6, $7, LOCALTIMESTAMP, $8,
default, default,$9)
returning order_id;
order_id 是 SERIAL 的类型 -> primary key
插入时出现如下错误:
PSQLException: ERROR: null value in column "order_id" violates not-null constraint Where: SQL function "insert_ABC" statement 1.
我正在使用PostgreSQL 8.2。它在我正在做的托管空间中。
我知道会发生错误,因为默认类型将 null 作为默认值。
SERIAL 类型的 default 的等价物是什么。
请指导我。
【问题讨论】:
标签: sql postgresql stored-procedures