The following procedure rounds the Timestamp(9) to a Timestamp(6):
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;
The call below will insert: 2007-12-12 12:23:45.123457000
@call DB.INSERT_ROW(TIMESTAMP '2007-12-12 12:23:45.123456789');
Whereas the code below will insert this: 2007-12-12 12:23:45.123456789
INSERT
INTO
DB.MY_TABLE
(
MY_TIMESTAMP
)
VALUES
(
TIMESTAMP '2007-12-12 12:23:45.123456789'
);
How do I prevent this? Using (myTimestamp IN TIMESTAMP(9)) fails to validate.
This should do the trick. Numerically constrained types are not permitted in a parameter list.