addToNumDuplicateRecordsScraped
void session.addToNumDuplicateRecordsScraped ( Object value ) (enterprise edition only)
Description
Add to the value of duplicate records scraped. (As opposed to new or error records.)
Parameters
- value Value to be added to the count. Usually a integer but if it is given a string (e.g. "10") it will try to transform it into an integer before adding.
Return Values
Returns void.
Change Log
Version | Description |
---|---|
7.0 | Available for enterprise edition. |
Examples
Record New Records Scraped
// Adds 10 to the value of new records scraped.
session.addToNumDuplicateRecordsScraped(10);
session.addToNumDuplicateRecordsScraped(10);
Have session record each time a new record saved to the database
// In script called "After each pattern match"
import java.sql.PreparedStatement;
import java.sql.ResultSet;
dm = session.getv("_DM");
con = dm.getConnection();
try
{
String sql = "SELECT id FROM table WHERE did = ?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, dataRecord.get("ID"));
ResultSet rs = pstmt.executeQuery();
if (rs.next())
{
log.log("---Already in DB");
session.addToNumDuplicateRecordsScraped(1);
}
else
{
session.scrapeFile("Results");
}
}
catch (Exception e)
{
log.logError(e);
session.setFatalErrorOccurred(true);
session.setErrorMessage(e);
}
finally
{
con.close();
}
import java.sql.PreparedStatement;
import java.sql.ResultSet;
dm = session.getv("_DM");
con = dm.getConnection();
try
{
String sql = "SELECT id FROM table WHERE did = ?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, dataRecord.get("ID"));
ResultSet rs = pstmt.executeQuery();
if (rs.next())
{
log.log("---Already in DB");
session.addToNumDuplicateRecordsScraped(1);
}
else
{
session.scrapeFile("Results");
}
}
catch (Exception e)
{
log.logError(e);
session.setFatalErrorOccurred(true);
session.setErrorMessage(e);
}
finally
{
con.close();
}
jason on 04/26/2018 at 10:59 am
- Printer-friendly version
- Login or register to post comments