Em um exercício da faculdade foi pedido o seguinte:
Em uma eleição presidencial existem tres candidatos. Os votos são informados por código. Os dados utilizados para a escrutinagem obedecem a seguinte codificação: 1, 2, 3 = votos para os respectivos candidatos; 4 = voto nulo; 5 = voto em branco. Escreva um programa em PlSql que calcule e escreva: O total de votos para cada candidato; O total de votos nulos; O total de votos em branco. Como finalizador do conjunto de votos, tem-se o valor 0 (zero).
Minha resposta foi a seguinte
declare
valorVoto number type:= &voto;
votosDeputado1 number:= 0;
votosDeputado2 number:= 0;
votosDeputado3 number:= 0;
votosNulos number;
votosBrancos number;
begin
if valorVoto = 1 then
votosDeputado2:=votosDeputado2 + 1;
end if;
if valorVoto = 2 then
votosDeputado2:=votosDeputado2 + 1;
end if;
if valorVoto = 3 then
votosDeputado3:=votosDeputado3 + 1;
end if;
if valorVoto = 4 then
votosNulos := votosNulos+1;
end if;
if valorVoto = 5 then
votosBrancos := votosbrancos+1;
end if;
DBMS_OUTPUT.PUT_LINE ('O primeiro candidato teve ' || votosDeputado1);
DBMS_OUTPUT.PUT_LINE ('O segundo candidato teve ' || votosDeputado2);
DBMS_OUTPUT.PUT_LINE ('O terceiro candidato teve ' || votosDeputado3);
DBMS_OUTPUT.PUT_LINE ('O total de votos nulos foi ' || votosNulos);
DBMS_OUTPUT.PUT_LINE ('O total de votos em branco foi ' || votosBrancos);
end;
porem a única saída que eu tenho é a seguinte
ORA-06550: linha 2, coluna 18: PLS-00103: Encontrado o símbolo "TYPE" quando um dos seguintes símbolos era esperado:
:= . ( @ % ; not nulo faixa default caractere O símbolo "." foi substituído por "TYPE" para continuar. 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. *Action:
Qual quer ajuda é bem vinda : )