Spring Framework
  1. Spring Framework
  2. SPR-8884

Error when parsing PMS stored procedure script.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 3.0.6
    • Fix Version/s: None
    • Component/s: Data
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      For testing purpose, I use EmbeddedDatabase.

      My database schema contains HSQLDB PMS stored procedures.

      like this one:

      ----------- content of procedure.sql (a valid HSQLDB PMS stored procedure) ---------------------
      CREATE PROCEDURE get_customer(IN id INT, OUT firstname VARCHAR(50), OUT lastname VARCHAR(50))
      READS SQL DATA
      BEGIN ATOMIC
      SELECT first_name, last_name INTO firstname, lastname FROM customers WHERE cust_id = id;
      END

      When I create database instance:

      EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
      database = builder.setType(EmbeddedDatabaseType.HSQL).addScript("classpath:/META-INF/sql/schema.sql")
      .addScript("classpath:/META-INF/sql/procedure.sql")
      .build();

      I get this exception:
      "an error occurs during parsing of procedure.sql
      org.hsqldb.HsqlException: unexpected end of statement: required: ; "

      The problem is not in HSQLDB part but is located in :
      org.springframework.jdbc.datasource.init.ResourceDatabasePopulator#splitSqlScript(String script, char delim, List<String> statements)
      it uses ';' character as a delimiter for statements and therefore creates 2 statements, one for [CREATE PROCEDURE .... cust_id = id] and the second for [END].
      The first statement is rejected by HSQLDB because of a missing ';' character in BEGIN block.

        Issue Links

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              Chris Beams
              Reporter:
              Vincent MONIER
              Last updater:
              Trevor Marshall
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                2 years, 21 weeks ago