I have two tables, one call coletor
, and another call material
, I have a proc
called cadMat
, which was to register material in the database and by cpf (parameter of proc) put as name of collector the materials that it brought when cpf exists in the database (with an update statement), but when doing this the instruction changes all lines, not some as expected, can anyone help me?
The code is here, if you can.
create proc cadMat /*Cadastra o material no banco de dados Ok!(sistema)*/
@cpfColetor char(12),
@nomeMaterial varchar(30),
@tipoMaterial varchar(8),
@zonaMaterial varchar(10),
@qtdeMaterial float,
@dataRecebimentoMaterial datetime
as
begin
insert into material values(@nomeMaterial,@tipoMaterial,@zonaMaterial,@qtdeMaterial,@dataRecebimentoMaterial,@cpfColetor,'')
update coletor
set qtdeMatCol +=@qtdeMaterial where cpfCol = @cpfColetor
update material set nomeColMat = nomeCol from coletor where cpfCol = @cpfColetor
end