diff --git a/jrunner/src/main/java/jrunner/jrunner.java b/jrunner/src/main/java/jrunner/jrunner.java index 080a22a..aef92aa 100644 --- a/jrunner/src/main/java/jrunner/jrunner.java +++ b/jrunner/src/main/java/jrunner/jrunner.java @@ -288,8 +288,20 @@ public class jrunner { // those messages to tell a real failure from a working TRUNCATE, // which made a non-zero exit code impossible to adopt. boolean hasResultSet = stmt.execute(sq); + // A stored procedure may report update counts before opening its + // cursor, and /opt/sync uses CALL statements as migration sources + // (rlarp.QUOTE_REBUILD and friends). Walk past any update counts to + // the first real result set instead of concluding there is none — + // executeQuery() would simply have thrown here. The last count is + // retained so a plain DML statement can still report rows affected. + int updated = -1; + while (!hasResultSet) { + int uc = stmt.getUpdateCount(); + if (uc == -1) break; // no further results of any kind + updated = uc; + hasResultSet = stmt.getMoreResults(); + } if (!hasResultSet) { - int updated = stmt.getUpdateCount(); if (!queryMode) { System.out.println("------------no result set---------------------------------"); System.out.println("rows affected: " + updated);