0

I have the following function:

Create or Replace Function someFunction([parameter1], [parameter2]) Returns Integer As $$
Declare
    someInt_ integer;
    totalRows_ integer;
Begin
    SELECT x INTO someInt_, COUNT(*) INTO totalRows_ 
    FROM [table]
    WHERE [some conditions];

    [more code]
End;
$$ Language 'plpgsql';

The problem is that I get the following error:

ERROR:  «count» is not a known variable
LINE 6:  SELECT x INTO someInt_, COUNT(*) INTO totalRows_ ...
                                 ^
SQL state: 42601
Character: 181

How can I fix this?

I know a lot of data is missing, such as the return. It is because I have simplified it since the variables are in another language.

1 Answer 1

2

The INTO comes after all columns:

SELECT x, COUNT(*)
   INTO someInt_, totalRows_ 
FROM [table]
WHERE [some conditions];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.