I'm adding records to a postgres database using a powershell script.
How can I tell how many records are in a transaction - or to put it another way how can I tell how many INSERT statements were executed between issuing a BEGIN, and closing it with a COMMIT?
I'm adding batches of records using code something like this....
$DBCmd = $DBConn.CreateCommand(); $DBCmd.CommandText = "INSERT xyz INTO blah" $n=$DBCmd.ExecuteNonQuery(); $insertedRec = $insertedRec + $n
Where $n is the number of records inserted. I start each batch with a BEGIN and periodically issue a COMMIT like this....
$DBCmd = $DBConn.CreateCommand(); $DBCmd.CommandText = "COMMIT; "; $z=$DBCmd.ExecuteNonQuery();
I'd like to do some reconciliation and confirm that the number of records I think I've INSERTed match the number of records COMMITed in the transaction. I had hoped that $z might tell me this but it doesn't.
Is there a simple way to achieve this?