From 62add16dc4c907cb535b419d40daa10aeb36d17a Mon Sep 17 00:00:00 2001 From: Guilherme Andrade Del Cantoni Date: Mon, 19 Nov 2018 10:04:40 -0200 Subject: [PATCH] Alinhamento de compatibilidade de scripts entre Oracle e SQLServer --- rn/ProcessoExpedidoRN.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/rn/ProcessoExpedidoRN.php b/rn/ProcessoExpedidoRN.php index c601975..956e5b3 100644 --- a/rn/ProcessoExpedidoRN.php +++ b/rn/ProcessoExpedidoRN.php @@ -15,9 +15,11 @@ class ProcessoExpedidoRN extends InfraRN { public function listarProcessoExpedido(ProtocoloDTO &$objProtocoloDTO) { $bolSqlServer = $this->getObjInfraIBanco() instanceof InfraSqlServer; + $bolOracle = $this->getObjInfraIBanco() instanceof InfraOracle; $numLimit = $objProtocoloDTO->getNumMaxRegistrosRetorno(); $numOffset = $objProtocoloDTO->getNumPaginaAtual() * $objProtocoloDTO->getNumMaxRegistrosRetorno(); $strInstrucaoPaginacao = (!$bolSqlServer) ? "LIMIT ".$numOffset.",".$numLimit : "OFFSET $numOffset ROWS FETCH NEXT $numLimit ROWS ONLY"; + $strInstrucaoPaginacao = ($bolOracle) ? "" : $strInstrucaoPaginacao; $sql = "SELECT p.id_protocolo, @@ -41,14 +43,20 @@ class ProcessoExpedidoRN extends InfraRN { ptra.dth_registro = (SELECT MAX(pt.dth_registro) dth_registro FROM md_pen_tramite pt WHERE pt.numero_registro = pe.numero_registro) AND NOT EXISTS ( - SELECT at2.* FROM atividade as at2 + SELECT at2.* FROM atividade at2 WHERE at2.id_protocolo = p.id_protocolo AND at2.id_tarefa = ". ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_RECEBIDO) ." AND at2.dth_abertura > a.dth_abertura ) GROUP BY p.id_protocolo, p.protocolo_formatado, a.id_unidade , atd.valor , us.id_usuario, us.nome, a.dth_abertura ORDER BY a.dth_abertura DESC ".$strInstrucaoPaginacao; - $sqlCount = "SELECT + + if ($this->getObjInfraIBanco() instanceof InfraOracle){ + $qtd = $numLimit + $numLimit; + $sql = "select a.* from ($sql) a where rownum >= $numOffset and rownum <= $qtd"; + } + + $sqlCount = "SELECT count(*) total FROM protocolo p INNER JOIN atividade a ON a.id_protocolo = p.id_protocolo @@ -64,13 +72,12 @@ class ProcessoExpedidoRN extends InfraRN { ptra.dth_registro = (SELECT MAX(pt.dth_registro) dth_registro FROM md_pen_tramite pt WHERE pt.numero_registro = pe.numero_registro) AND NOT EXISTS ( - SELECT at2.* FROM atividade as at2 + SELECT at2.* FROM atividade at2 WHERE at2.id_protocolo = p.id_protocolo AND at2.id_tarefa = ". ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_RECEBIDO) ." AND at2.dth_abertura > a.dth_abertura ) "; - - +//die($sql); $pag = $this->getObjInfraIBanco()->consultarSql($sql); $count = $this->getObjInfraIBanco()->consultarSql($sqlCount); $total = $count ? $count[0]['total'] : 0; -- libgit2 0.21.2