以下過程舍入時間戳(9)爲Timestamp(6):時間戳的舍入(9)中的Oracle 11g存儲過程
CREATE
TABLE MY_TABLE
(
MY_TIMESTAMP TIMESTAMP(9) NOT NULL
)
CREATE OR REPLACE PROCEDURE "DB"."INSERT_ROW"
(myTimestamp IN TIMESTAMP)
AS
v_sys_error NUMBER := 0;
v_err INTEGER;
v_rc INTEGER;
BEGIN
BEGIN
INSERT
INTO
DB.INSERT_ROW
(
MY_TIMESTAMP
)
VALUES
(
myTimestamp
);
EXCEPTION
WHEN OTHERS THEN
v_sys_error := SQLCODE;
v_err := v_sys_error;
v_rc := SQL%ROWCOUNT;
RAISE;
END;
END;
下面的調用將插入:2007-12-12 12: 23:45.123457000
@call DB.INSERT_ROW(TIMESTAMP '2007-12-12 12:23:45.123456789');
而下面的代碼將插入這樣的:2007-12-12 12:23:45.123456789
INSERT
INTO
DB.MY_TABLE
(
MY_TIMESTAMP
)
VALUES
(
TIMESTAMP '2007-12-12 12:23:45.123456789'
);
如何避免這種情況?使用(myTimestamp IN TIMESTAMP(9))無法驗證。
確定表列足夠寬? – kurosch 2011-01-21 22:23:18