Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. -- --------------------------------------------------------------------------------
  2. -- Routine DDL
  3. -- Note: comments before and after the routine body will not be stored by the server
  4. -- --------------------------------------------------------------------------------
  5. DELIMITER $$
  6.  
  7. CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_processoFinalizado`(IN mantenedor int(11))
  8. BEGIN
  9.  
  10. select
  11. `p`.`protocolo` AS `protocolo`,
  12. `p`.`id` AS `idProcesso`,
  13. `p`.`der` AS `der`,
  14. `p`.`data_habilitacao` AS `dhab`,
  15. `p`.`id_usuario` AS `idUsuario`,
  16. p.mantenedor as mantenedor,
  17. `ap`.`id_andamento` AS `codAndamento`,
  18. `ap`.`data` AS `dataAndamento`,
  19. `ap`.`observacao` AS `observacao`,
  20. `ap`.`id_usuario` AS `idUsuarioEvento`,
  21. `u`.`nome` AS `nome`,
  22. `u`.`matricula` AS `matricula`,
  23. `u`.`lotacao` AS `lotacao`,
  24. (to_days(`ap`.`data`) - to_days(`p`.`der`)) AS `tempoConclusao`,
  25. (to_days(`ap`.`data`) - to_days(`p`.`data_habilitacao`)) AS `tempoDecisao`,
  26. `a`.`descricao` AS `desAndamento`
  27. from
  28. (((`processo` `p`
  29. join `andamento_processo` `ap` ON ((`p`.`id` = `ap`.`id_processo`)))
  30. join `usuario` `u` ON ((`u`.`id` = `p`.`id_usuario`)))
  31. join `andamento` `a` ON ((`ap`.`id_andamento` = `a`.`id`)))
  32. where
  33. (`p`.`bol_finalizado` = 'S')
  34. and p.mantenedor = mantenedor
  35. order by `p`.`der` , `p`.`data_habilitacao`;
  36.  
  37.  
  38. END
  39.  
  40. CALL sp_processoFinalizado(2225566) where tempoDecisao < 30;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement