Duvidas Procedure

Firebird

19/06/2006

Oi pessoal

Tenho 3 duvidas:
- como colcocar tipo echo ´passei por aqui´ em Interbase (uso dialect 1)
- o exemplo a baixo se usar FOR .... DO, se o select devolver mais q um registo ele percorre todos os registos ou terei uecriar um CURSO ou usar um FOREACH caso exista em Interbase.
- ao usar exception maquso dá como terminada o ciclo/procedure ou terei que fazer um break (caso exista este comando Interbase)

AS
declare variable Qmaquina char(10);
declare variable IDexiste integer;
declare variable qualtrab integer;
declare variable temparagem integer;
begin
/*verifica qual a maquina q tenta utilizar*/
select maquina from trabalho where id=old.id into :qmaquina ;

/*verifica se essa maquina ja esta a ser usada por outro trabalhador*/
select count(maquina)
from trabalho
where datafim is null
and maquina=:qmaquina
group by maquina
INTO :IDexiste;

/*encontro registo, porque maquina esta a ser usada*/
if (:IDexiste is not null) then
begin
printf (´¬d´,:IDexiste) ;
/*verificar qual NP/OS */
for
select id from trabalho where maquina = :qmaquina and datafim is null order by id desc into :qualtrab
do
begin
for select id from paragem where id= :qualtrab into :temparagem
do
if (:temparagem is null) then
begin
exception maquso;
end

/*verificar se essa NP/OS tem paragens trab registadas*/
for select id from paragem where id= :qualtrab and datafim is null into :temparagem
do
if (:temparagem is null) then
begin
exception maquso;
end
end
end

end[/list]


Nilpedro

Nilpedro

Curtidas 0
POSTAR