问题
I have the following function:
CREATE OR REPLACE Function pode_levar( pedidos NUMBER, viagens NUMBER)
RETURN NUMBER
IS
x NUMBER:=0;
y NUMBER:=0;
TRUE NUMBER:=0;
BEGIN
BEGIN
Select id_pedido into x
from pedido
where id_pedido = pedidos;
EXCEPTION
WHEN NO_DATA FOUND THEN
RAISE_APPLICAITON_ERROR(-20305,'PEDIDO TRANSPORTE ENIXISTENTE');
END;
BEGIN
select lim_vei_vol - volume_total_viagem(viagens) into y
from v viagem , ve veiculo
where v.id_viagem = ve.id_viagem
and id_viagem = viagens;
EXCEPTION
WHEN NO_DATA_FOUND THEN
TRUE:=0;
RAISE_APPLICATION_ERROR(-20304,'Viagem Enixistente');
RETURN(TRUE);
END;
BEGIN
IF y <> 0
TRUE := 1;
RETURN(TRUE);
ELSE
TRUE := 0;
RETURN(TRUE);
ENDIF;
END;
END;
The function compiles with one warning, how can I see it? show errors
does not work
This is for school,
回答1:
You should use SQL* Plus and set
ALTER SESSION SET PLSQL_WARNINGS = 'ENABLE:ALL';
before you create your function. This setting will show you any warnings by using
SHOW ERRORS;
Read: http://docs.oracle.com/cd/B28359_01/server.111/b28320/initparams186.htm#REFRN10249
回答2:
Not sure why you aren't seeing this with show errors
- possibly a buggy old version. You can try this instead:
select * from user_errors;
But you have your aliases declared the wrong way around and not always used when referencing the shared column:
from v viagem , ve veiculo
where v.id_viagem = ve.id_viagem
and id_viagem = viagens;
should be:
from viagem v, veiculo ve
where v.id_viagem = ve.id_viagem
and v.id_viagem = viagens;
Or even:
from viagem v
join veiculo ve
on v.id_viagem = ve.id_viagem
where v.id_viagem = viagens;
There may be are other problems too as Ben pointed out in comments, and you haven't shown any table definitions, but that wasn't really the question.
If you had warnings turned on too (which is in the preferences in SQL Developer) I'd guess it would point out that the return
after the raise
in the second block is unreachable. You can't do both.
来源:https://stackoverflow.com/questions/17013487/display-pl-sql-function-warnings