Subject | Problem with dates in SP |
---|---|
Author | Marco Lauria |
Post date | 2002-08-19T08:26:29Z |
Hello,
I tried to write a stored procedure that returns the rows in a table older
than a number
of hours.
Here it's the code:
CREATE PROCEDURE GET_INTERVENTI_SCADUTI (
P_DELTA TIMESTAMP)
RETURNS (
ID_INTERVENTI NUMERIC (18, 0))
AS
declare variable DELTA_TIME TIMESTAMP;
BEGIN
DELTA_TIME = CAST ('now' AS TIMESTAMP);
DELTA_TIME = DELTA_TIME - :P_DELTA;
FOR SELECT ID_INTERVENTI FROM INTERVENTI
WHERE ORA_INVIO < :DELTA_TIME AND ((INVIATO IS NULL) or (INVIATO=0))
INTO :ID_INTERVENTI
DO BEGIN
SUSPEND;
END
/* Procedure body */
if (ID_INTERVENTI IS NULL) then
SUSPEND;
END
I tried also with P_DELTA declared as TIME using a type cast in the
subtraction.
The problem is that I receive a "conversion error from string 30XXX.YYYYY"
on the instruction:
DELTA_TIME = DELTA_TIME - :P_DELTA;
Can anyone here help me?
Regards
Marco
Best Regards,
Marco Lauria
STARMAX s.a.s.
TEL. +39-091-6880476
FAX. +39-091-6887202
MOB. +39-348-3547034
[Non-text portions of this message have been removed]
I tried to write a stored procedure that returns the rows in a table older
than a number
of hours.
Here it's the code:
CREATE PROCEDURE GET_INTERVENTI_SCADUTI (
P_DELTA TIMESTAMP)
RETURNS (
ID_INTERVENTI NUMERIC (18, 0))
AS
declare variable DELTA_TIME TIMESTAMP;
BEGIN
DELTA_TIME = CAST ('now' AS TIMESTAMP);
DELTA_TIME = DELTA_TIME - :P_DELTA;
FOR SELECT ID_INTERVENTI FROM INTERVENTI
WHERE ORA_INVIO < :DELTA_TIME AND ((INVIATO IS NULL) or (INVIATO=0))
INTO :ID_INTERVENTI
DO BEGIN
SUSPEND;
END
/* Procedure body */
if (ID_INTERVENTI IS NULL) then
SUSPEND;
END
I tried also with P_DELTA declared as TIME using a type cast in the
subtraction.
The problem is that I receive a "conversion error from string 30XXX.YYYYY"
on the instruction:
DELTA_TIME = DELTA_TIME - :P_DELTA;
Can anyone here help me?
Regards
Marco
Best Regards,
Marco Lauria
STARMAX s.a.s.
TEL. +39-091-6880476
FAX. +39-091-6887202
MOB. +39-348-3547034
[Non-text portions of this message have been removed]