Question

I am getting an error in PCC which doesn't make a lot of sense. I have two statements inside a user defined function that are nearly exactly the same and one runs fine while the other is returning an error:

'INTO': Syntax error

end and start are parameters being passed to the function.

The Error is being thrown on the second INTO statement

SELECT count(*) INTO :divModelTot1
FROM "table1"."info" i
WHERE i.compldate <:end
AND (i.agree is null OR i.agree>:start)
UNION ALL
SELECT count(*) INTO :divModelTot2
FROM "table2"."info" i
WHERE i.compldate <:end
AND (i.agree is null or i.agree>:start);

Any help or suggestions would be appreciate.

Thanks!

Was it helpful?

Solution

SELECT INTO must be the first query in a statement containing a UNION.

SELECT count(*) INTO :divModelTot1
FROM "table1"."info" i
WHERE i.compldate <:end
AND (i.agree is null OR i.agree>:start)
UNION ALL
SELECT count(*)
FROM "table2"."info" i
WHERE i.compldate <:end
AND (i.agree is null or i.agree>:start);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top