I need to know how many records were entered in the query below.
public function CadastraCliente() {
$this->conn->beginTransaction();
try {
$stmt = $this->conn->prepare("
INSERT INTO SISCli (CdInscricao,DsEntidade,DsApelido,InInscricao,InCadastro,DsEndereco,NrCEP,NrInscricaoEstadual,NrCGCCPF,NrTelefone,DtCadastro,CdEmpresa,DsEMail,DsUSuarioInc,InClassificacaoFiscal,DsBairro)
SELECT
right( ('00000000' + cast(ESP353_XML.DES_NrCGCCPF as varchar)), 14) as [CdInscricao],
ESP353_XML.DES_DsEntidade AS [DsEntidade],
ESP353_XML.DES_DsApelido AS [DsApelido],
ESP353_XML.DES_InInscricao,
0 AS [InCadastro],
ESP353_XML.DES_DsEndereco AS [DsEndereco],
ESP353_XML.DES_NrCEP AS [NrCEP],
ESP353_XML.DES_NrInscricaoEstadual AS [NrInscricaoEstadual],
case when LEN(ESP353_XML.DES_NrCGCCPF) > 11
then right( ('00'+ cast(ESP353_XML.DES_NrCGCCPF as varchar)), 14)
else right( ('00000'+ cast(ESP353_XML.DES_NrCGCCPF as varchar)), 11)
end as [NrCGCCPF],
ESP353_XML.DES_NrTelefone AS [NrTelefone],
GETDATE() AS [DtCadastro],
case when SISCEP.DsUF='SP' then '4'
when SISCEP.DsUF='PR' then '3'
when SISCEP.DsUF='SC' then '12'
ELSE '1' END
as [CdEmpresa],
ESP353_XML.DES_DsEMail as [DsEMail],
'EdiXML' AS [DsUSuarioInc],
ESP353_XML.DES_InClassificacaoFiscal,
substring(ISNULL(ESP353_XML.DES_DsBairro,0),1,15) as [DES_DsBairro]
FROM ESP353_XML
LEFT JOIN SISCEP ON SISCEP.NrCep = ESP353_XML.DES_NrCEP
where not exists (select 1 from SISCli A WHERE cast(A.CdInscricao as numeric) = cast(ESP353_XML.DES_NrCGCCPF as numeric))
");
$stmt->execute();
$this->conn->commit();
} catch (Exception $e) {
$this->conn->rollback();
echo $e;
}
}
What I've already tried:
$stmt->execute();
$count = $stmt->rowCount();
print_r($count);