Subject | Re: [ib-support] SELECT INTO local variable appears to be not working |
---|---|
Author | Helen Borrie |
Post date | 2003-05-27T22:27:23Z |
At 10:43 PM 27/05/2003 +0100, you wrote:
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;
heLen
>I have a stored procedure along the following lines:You need this (colon preceding the variable name):
>
>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
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;
heLen