$sql = "delete from ast_eventos_dacs a where cast(to_timestamp(uid1::numeric) as date) < (now()::date - $numDias) and exists(select '' from pbx_eventos_dacs where id = a.id)";
$sql = "delete from ast_bilhetes a where calldate::date < (now()::date - $numDias) and exists(select '' from pbx_bilhetes where id_bilhetes = a.id_bilhetes)";
if ($beginTran)
$result = pg_query($dbcon, $sql);
$numRegDel = @pg_affected_rows($result);
if ($result) {
$result = pg_query($dbcon, 'commit');
$msg = "Opera<EFBFBD><EFBFBD>o realizada com sucesso! Registros excluidos: $numRegDel";
__WriteLog__($nomeProc, $msg, true);
return true;
} else {
if ($beginTran) {
pg_query($dbcon, 'rollback');
}
$msg = "N<EFBFBD>o foi poss<EFBFBD>vel realizar a opera<EFBFBD><EFBFBD>o.";
$sql = "delete from ast_bilhetes_complemento a where data_registro::date < (now()::date - $numDias) and exists(select '' from pbx_bilhetes_complemento where id = a.id)";
if ($beginTran) {
$result = pg_query($dbcon, $sql);
}
$numRegDel = @pg_affected_rows($result);
if ($result) {
$result = pg_query($dbcon, 'commit');
$msg = "Opera<EFBFBD><EFBFBD>o realizada com sucesso! Registros excluidos: $numRegDel";
__WriteLog__($nomeProc, $msg, true);
return true;
} else {
if ($beginTran) {
pg_query($dbcon, 'rollback');
}
$msg = "N<EFBFBD>o foi poss<EFBFBD>vel realizar a opera<EFBFBD><EFBFBD>o.";
where tlvb_mes = (extract('month' from now()) - 1)
and not exists(select '' from pbx_televendas_reg where tlvb_id = a.tlvb_id);
delete from pbx_televendas_bloqueio a where tlvb_mes = (extract('month' from now()) - 1) and exists(select '' from pbx_televendas_reg where tlvb_id = a.tlvb_id);";