Retrieve rejected records after COPY command

Moderator: NorbertKrupa

Post Reply
caprile
Newbie
Newbie
Posts: 13
Joined: Tue May 29, 2012 1:24 pm

Retrieve rejected records after COPY command

Post by caprile » Tue May 29, 2012 1:33 pm

Hi,
I implements a java loader component and use COPY statement in order to load the data into Vertica.
This is a snippet of my java code :
....
Connection connection = DriverManager.getConnection(connectionUrl, username, password);
try {
String sql = "COPY public.TEST_LOAD_TABLE (A, B, DATADATE FORMAT 'YYYYMMDDHH24MISS', N) FROM STDIN DELIMITER '|' TRAILING NULLCOLS DIRECT NO COMMIT;"
FileInputStream file = new FileInputStream(workingFile);
connection.setAutoCommit(false);
PGStatement stmt = (PGStatement) connection.createStatement();
stmt.executeCopyIn(sql, file);
} catch (Exception ex) {
connection.rollback();
throw ex;
}
connection.commit();
........

During the copy statement I have some reject records, but I need to know which records has been rejected in order to edit e reload these ones.
Does exist a way to retrieve the rejected records?

id10t
GURU
GURU
Posts: 732
Joined: Mon Apr 16, 2012 2:44 pm

Re: Retrieve rejected records after COPY command

Post by id10t » Tue May 29, 2012 2:19 pm

Hi caprile!

What Vertica version you are using? and JDBC drivers? 3.5? 4.1?

PS
http://my.vertica.com/docs/5.0/JDBC/index.html
Interface PGStatement has declaration of next method getNumRejectedRows() (but it deprecated as of 4.1)
If you will migrate to Vertica JDBC 5.1 drivers here example

caprile
Newbie
Newbie
Posts: 13
Joined: Tue May 29, 2012 1:24 pm

Re: Retrieve rejected records after COPY command

Post by caprile » Tue May 29, 2012 5:20 pm

Hi,
I'm using Vertica 5.0 and the java component VerticaCopyStream is not available,
I will migrate to Vertica 5.1 because is much important for my business to have the references to the rejected rows so I can reload these ones.
Thank you very much!!

Post Reply

Return to “JDBC”