It seems as if session variables in stored procedures are not necessarily initialized with 'NULL' on 'BEGIN'.
CREATE PROCEDURE UPSERT_CloudGroupUserMap(
IN inGroupName text,
OUT outID int)
SELECT GroupID INTO @GroupId
WHERE Name = inGroupName;
SET outStatus = @GroupId;
If the query does not return any rows (because the 'Name' does not match), the variable '@GroupId' contains the result of the previous query, instead of 'NULL' which I'd expect.
SET @GroupId = NULL;
before the query.
Any Ideas why this might happen?