All pastes #267281 Raw Edit

Anonymous

public sql v1 · immutable
·published 2006-12-04 19:28 UTC
rendered paste body
create or replace package projeto_final as  type ret_voo is record (num_voo voo.numero%type,                          cia voo.companhiaaerea%type,                          origem aeroporto.nome%type,                          destino aeroporto.nome%type,                          cidade_vem aeroporto.cidade%type,                          cidade_vai aeroporto.cidade%type,                          hora_chegada instanciatrecho.horachegada%type,                          hora_saida instanciatrecho.horasaida%type);  type array_voo is varray(1) of ret_voo;                            procedure consulta_voo (origem aeroporto.cidade%type,                          destino aeroporto.cidade%type,                          data_saida instanciatrecho.data%type,                          hora_li instanciatrecho.horasaida%type, -- limite inferior para a hora de partida                          hora_ls instanciatrecho.horasaida%type, -- limite superior para a hora de partida                          retorno_voo OUT NOCOPY array_voo);end projeto_final;CREATE OR REPLACE package body projeto_final as   procedure consulta_voo (origem aeroporto.cidade%type,                          destino aeroporto.cidade%type,                          data_saida instanciatrecho.data%type,                          hora_li instanciatrecho.horasaida%type, -- limite inferior para a hora de partida                          hora_ls instanciatrecho.horasaida%type, -- limite superior para a hora de partida                          retorno_voo OUT NOCOPY array_voo) is                                  cursor c_voo (cidade_org aeroporto.cidade%type,                      cidade_dst aeroporto.cidade%type,                      data_saida instanciatrecho.data%type,                      hora_li instanciatrecho.horasaida%type,                      hora_ls instanciatrecho.horasaida%type) is                                            select voo.numero, voo.companhiaaerea, sai.nome, chega.nome, sai.cidade, chega.cidade, instanciatrecho.horachegada, instanciatrecho.horasaida                      from aeroporto sai, voo, aeroporto chega, instanciatrecho                      where instanciatrecho.data = data_saida                            and instanciatrecho.aeroportcodsai = sai.aeroportcod                            and instanciatrecho.aeroportcodchega = sai.aeroportcod                            and instanciatrecho.horasaida >= hora_li                            and instanciatrecho.horachegada <= hora_ls                            and instanciatrecho.numerovoo = voo.numero                            and sai.cidade = cidade_org                            and chega.cidade = cidade_dst;    begin        for instancia in c_voo(origem, destino, data_saida, hora_li, hora_ls) loop            retorno_voo(retorno_voo.last) := instancia;            retorno_voo.extend; -- append a null element        end loop;        retorno_voo.trim; -- remove the last null element   end consulta_voo;end projeto_final;