1
In a college exercise the following was requested:
In a presidential election there are three candidates. Votes are by code. The data used for screening are codified as follows: 1, 2, 3 = votes for their respective candidates; 4 = invalid vote; 5 = blank vote. Write a program Plsql that calculates and writes: The total votes for each candidate; The total of null votes; The total of blank votes. As finalizer of the set of votes, the value is 0 (zero).
My answer was this:
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;
but the only way out is this
ORA-06550: row 2, column 18: PLS-00103: "TYPE" symbol found when one of the following symbols was expected:
:= . ( @ % ; not null range default character The symbol "." was replaced by "TYPE" to continue. 06550. 00000 - "line %s, column %s: n%s" *Cause: Usually a PL/SQL Compilation error. *Action:
Who wants help is welcome : )
What you wanted with the valueVoto number type:= &vote; ?
– Motta