0
I created a procedure
to make the following process:
If you do not enter the required parameter, you will bring the complete list of what I want (in this case a list of students etc).
If you type, it will bring the specific student.
But instead, she only brings it back if I type the id
of the student, ignoring the condition IF P_idAluno IS NULL THEN
.
BEGIN IF (P_idAluno IS NULL)
THEN SELECT A.idAluno AS CodigoAluno,
A.NomeAluno AS Nome, A.SexoAluno AS Sexo, A.DataNascimento, T.Turma,
S.Serie, T.Turno
FROM tbAluno A
INNER JOIN tbTurma T ON T.idTurma = A.id_Turma
INNER JOIN tbSerie S ON S.idSerie = T.id_Serie
ORDER BY A.NomeAluno;
ELSE
SELECT A.idAluno AS CodigoAluno, A.NomeAluno AS
Nome, A.SexoAluno AS Sexo, A.DataNascimento, T.Turma, S.Serie, T.Turno
FROM tbAluno A
INNER JOIN tbTurma T ON T.idTurma = A.id_Turma
INNER JOIN tbSerie S ON S.idSerie = T.id_Serie WHERE idAluno = P_idAluno;
END IF;
END
try something like ... idAluno = COALESCE(P_idaluno , idAluno ) in Where , passed the parameter looks for a student , null past behind all
– Motta
How are you calling Procedure? P_idaluno is being passed as either null or 0?
– Leonardo Buta
I’m calling the precedent: spAlunoTurma. CREATE PROCEDURE'spAlunoTurma'(P_idaluno INT)[...]
– Iago Neves