DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=?;AT YEAR YEARS MONTH MONTHS DAY DAYS HOUR HOURS MINUTE MINUTES, DRIVER=3.64.82

DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=?;AT YEAR YEARS MONTH MONTHS DAY DAYS HOUR HOURS MINUTE MINUTES, DRIVER=3.64.82

我的代码是这样的:

addToTable2(ObjectDTO objectDTO) {
   def sql = sql.execute(
    """INSERT INTO SCHEMA.TABLE2 (
        COLUMN1,
        COLUMN2,
        COLUMN3 )
        VALUES (
         ${objectDTO.property1}
         ${objectDTO.property2}
         ${objectDTO.property3})""")
}



ArrayList<ObjectDTO> fetchValuesFromTable1() throws CollectionsException {

    ArrayList<ObjectDTO> fetchValues= new ArrayList<ObjectDTO>()
    def sql = """
        SELECT *
        FROM SCHEMA.TABLE1
        ORDER BY DATE DESC FETCH FIRST 1 ROW ONLY"""

    try {
      if(this.sql != null) {
        this.sql.eachRow(sql) {
          resultSet ->
            ObjectDTO objectDTO = new ObjectDTO()
            objectDTO.setProperty1(resultSet.PROPERTY1)
            objectDTO.setProperty2(resultSet.PROPERTY2)
            objectDTO.setPropety3(resultSet.PROPERTY3)
      
             objectList.add(poulSifr)
           }
         }

      for(ObjectDTO objectDTO: objectList) {
        addToTable2(objectDTO)
      }

    } catch (SQLException se) {
      log.info "fetchValues error $se.message  executed sql: $sql"
       throw new CollectionsException("fetchValues message $se.message")
    } finally {
      if (this.sql != null) {
        this.sql.close()
      }
    }
    objectList
  } 

我知道了 error/warning:

WARN groovy.sql.Sql - Failed to execute: INSERT INTO SCHEMA.TABLE ( COLUMN1, COLUMN2, COLUMN3 ) VALUES ( ?, ?, null)

because: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=?;AT YEAR YEARS MONTH MONTHS DAY DAYS HOUR HOURS MINUTE MINUTES, DRIVER=3.64.82

每当我从 Table1 中获取最后一个值时,我都需要将其放入 Table2 中。我不知道这是正确的方法还是我做的事情完全错误。

您在插入的 VALUES(...) 部分缺少逗号