Subject | SELECT INTO local variable appears to be not working |
---|---|
Author | Noel Cosgrave |
Post date | 2003-05-27T21:43:24Z |
I have a stored procedure along the following lines:
DECLARE VARIABLE VIEWCOUNT INTEGER;
BEGIN
SELECT COUNT(ACCESS_LOG_ID) FROM WEB_USERACCESSLOG WHERE CURRENT_TIMESTAMP - LOG_DATE <= 7 AND USER_ID = :USER_ID AND
PROJECT_ID = :PROJECT_ID INTO VIEWCOUNT;
SELECT PROJECT_NAME FROM PROJECTS WHERE PROJECT_ID = :PROJECT_ID INTO :PROJECT_NAME;
SUSPEND;
IF (VIEWCOUNT = 0) THEN
BEGIN
INSERT INTO USERACCESSLOG VALUES (-1,:USER_ID,:PROJECT_ID,CURRENT_TIMESTAMP);
END
END
The VIEWCOUNT variable always seems to contain the value 0 regardless
as to whether the SELECT COUNT query would normally return values
grater than 0. Is it not possible to select into local variables in
Interbase? The idea is to log the access to the PROJECTS table only
if access has not already been logged for the user in the previous 7
days.
Thanks for any assistance on this one.
P.S: Tried this in both Firebird 1.0.2 and Interbase 6, neither works
DECLARE VARIABLE VIEWCOUNT INTEGER;
BEGIN
SELECT COUNT(ACCESS_LOG_ID) FROM WEB_USERACCESSLOG WHERE CURRENT_TIMESTAMP - LOG_DATE <= 7 AND USER_ID = :USER_ID AND
PROJECT_ID = :PROJECT_ID INTO VIEWCOUNT;
SELECT PROJECT_NAME FROM PROJECTS WHERE PROJECT_ID = :PROJECT_ID INTO :PROJECT_NAME;
SUSPEND;
IF (VIEWCOUNT = 0) THEN
BEGIN
INSERT INTO USERACCESSLOG VALUES (-1,:USER_ID,:PROJECT_ID,CURRENT_TIMESTAMP);
END
END
The VIEWCOUNT variable always seems to contain the value 0 regardless
as to whether the SELECT COUNT query would normally return values
grater than 0. Is it not possible to select into local variables in
Interbase? The idea is to log the access to the PROJECTS table only
if access has not already been logged for the user in the previous 7
days.
Thanks for any assistance on this one.
P.S: Tried this in both Firebird 1.0.2 and Interbase 6, neither works