*** SQLExec.java.original Thu Aug 19 10:56:21 2004 --- SQLExec.java Fri Sep 10 10:13:47 2004 *************** *** 74,79 **** --- 74,85 ---- */ public class SQLExec extends JDBCTask { + private static final String BEGIN = "BEGIN"; + private static final String END = "END"; + + private boolean inBlockStatement; + private int blockDepth; + /** * delimiters we support, "normal" and "row" */ *************** *** 429,450 **** BufferedReader in = new BufferedReader(reader); while ((line = in.readLine()) != null) { if (!keepformat) { line = line.trim(); } line = getProject().replaceProperties(line); - if (!keepformat) { if (line.startsWith("//")) { continue; } if (line.startsWith("--")) { continue; } StringTokenizer st = new StringTokenizer(line); if (st.hasMoreTokens()) { String token = st.nextToken(); if ("REM".equalsIgnoreCase(token)) { continue; } } } --- 435,470 ---- BufferedReader in = new BufferedReader(reader); while ((line = in.readLine()) != null) { + // flag whether the current line is a comment + // or not. + boolean isComment = false; + if (!keepformat) { line = line.trim(); } line = getProject().replaceProperties(line); if (line.startsWith("//")) { + if (!keepformat) { continue; + }else{ + isComment = true; + } } if (line.startsWith("--")) { + if (!keepformat) { continue; + }else{ + isComment = true; + } } StringTokenizer st = new StringTokenizer(line); if (st.hasMoreTokens()) { String token = st.nextToken(); if ("REM".equalsIgnoreCase(token)) { + if (!keepformat) { continue; + }else{ + isComment = true; } } } *************** *** 463,470 **** sql.append("\n"); } } if ((delimiterType.equals(DelimiterType.NORMAL) ! && sql.toString().endsWith(delimiter)) || (delimiterType.equals(DelimiterType.ROW) && line.equals(delimiter))) { --- 483,497 ---- sql.append("\n"); } } + + // determine if a block statement has started or ended. + if(!isComment){ + containsBlockStatement(line); + } + if ((delimiterType.equals(DelimiterType.NORMAL) ! && sql.toString().endsWith(delimiter) ! && !inBlockStatement) || (delimiterType.equals(DelimiterType.ROW) && line.equals(delimiter))) { *************** *** 479,484 **** --- 506,548 ---- } } + /** + * Determines if the supplied line starts or ends + * a block statement. + *
+ * The start of a block statement is considered to be + * a line that trims to "BEGIN" or "BEGIN" + delimiter (case insensitive) + *