Syntax error in solution for "Stored Procedure ProjektZuteilen für das AngProj-Projekt"
Context
Stored Procedures, exercise 5
Summary
(Summarize the issue encountered concisely)
Steps to reproduce
Try to run the following on DB AngProj
schema public
:
CREATE OR REPLACE FUNCTION AngInProjekt (AngId IN INTEGER, ProjId IN INTEGER)
RETURNS INTEGER AS $$
DECLARE
p_n Projektzuteilung.ProjNr%TYPE:=-1;
BEGIN
SELECT (ProjNr, -1) INTO p_n
FROM ProjektZuteilung
WHERE PersNr = AngId AND ProjNr = ProjId;
RETURN p_n;
END;
$$ LANGUAGE plpgsql;
SELECT AngInProjekt(1001, 26);
What is the current issue behavior?
ERROR: invalid input syntax for integer: "(26,-1)"
CONTEXT: PL/pgSQL function anginprojekt(integer,integer) line 5 at SQL statement
********** Error **********
ERROR: invalid input syntax for integer: "(26,-1)"
SQL state: 22P02
Context: PL/pgSQL function anginprojekt(integer,integer) line 5 at SQL statement
What is the expected correct behavior?
(unsure. Some integer, I guess?)
Relevant logs and/or screenshots
(none)
Possible fixes
Removing the parentheses seems to solve the problem, but I don't understand the code. Are two columns being select
ed here? If so, how can they be crammed into a single INTEGER
return value? Should there be a COALESCE
?