不兼容的数据类型(hypersql)

问题描述 投票:-1回答:1

为什么我会收到不兼容的数据类型错误?

int blockSize = 100;
String city="London";
" select * from"+
"(" +
" select l.* from lottotable as l where l.city='"+city+"' and  l.date< cast('"+date+"' as date) order by l.date desc " +
")" +
" order by date asc limit CONVERT("+blockSize+", SQL_INTEGER )"

错误是:

java.sql.SQLSyntaxErrorException:操作中不兼容的数据类型:;在语句中的LIMIT,OFFSET或FETCH [select * from(select l。* from lottotable as l where l.city ='London'和l.date <cast('2018-9-21'as date)order by l。 date desc)按日期排序asc limit CONVERT(100,SQL_INTEGER)]

德比正常关闭

更新:表结构非常简单LOTTOTABLE(DATE,CITY,P1,P2,P3,P4,P5); p1到p5是整数,date是类型date,city是varchar

java jdbc hsqldb jdbc-odbc
1个回答
1
投票

按照评论中的建议更改查询:

int blockSize = 100;
String city="London";
String queryText =
    " select * from"+
    "(" +
    " select l.* from lottotable as l where l.city='"+city+"' and  l.date< cast('"+date+"' as date) order by l.date desc " +
    ")" +
    " order by date asc limit "+blockSize;
© www.soinside.com 2019 - 2024. All rights reserved.