Re: can't convert tinyint to boolean, a bug in hsqldb?
Fred Toussi <[email protected]> Mon, 08 Feb 2016 23:49:08 +0000
| Newsgroups | gmane.comp.java.hsqldb.user |
|---|---|
| Message-ID | <1454975348.2068456.515655082.07A568DC@webmail.messagingengine.com> |
The documentation refers to setting values for BOOLEAN columns using 1 or 0 in INSERT statements. In SELECT statements you can of course select the TINYINT: SELECT active AS status from sometable But you cannot treat it as a BOOLEAN in a CASE WHEN or WHERE clause. Instead of "WHERE active", you need to use "WHERE active = 1". Fred On Mon, Feb 8, 2016, at 22:00, Lenjoy wrote: > I have to use > `select active=1 as status from sometable;` > instead. > > On Mon, Feb 8, 2016 at 1:47 PM, Lenjoy <[email protected]> wrote: >> According to the hsqldb doc >> http://hsqldb.org/doc/guide/sqlgeneral-chapt.html#sgc_boolean_type >> TINYINT can be converted to boolean >> >> The table is created as >> " active tinyint NOT NULL" + >> >> But got error message when query as below in java code: >> `select active as status from sometable;` >> >> >> java.sql.SQLSyntaxErrorException: data type of expression is not >> boolean >> at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) >> at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) >> at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source) >> at org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source) >> ... my own library at >> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImp- l.java:62) >> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce- ssorImpl.java:43) >> at java.lang.reflect.Method.invoke(Method.java:497) >> at junit.framework.TestCase.runTest(TestCase.java:176) >> at junit.framework.TestCase.runBare(TestCase.java:141) >> at junit.framework.TestResult$1.protect(TestResult.java:122) >> at junit.framework.TestResult.runProtected(TestResult.java:142) >> at junit.framework.TestResult.run(TestResult.java:125) >> at junit.framework.TestCase.run(TestCase.java:129) >> at junit.framework.TestSuite.runTest(TestSuite.java:255) >> at junit.framework.TestSuite.run(TestSuite.java:250) >> at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunne- r.java:84) >> at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provid- er.java:283) >> at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUn- it4Provider.java:173) >> at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit- 4Provider.java:153) >> at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provide- r.java:128) >> at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameCl- assLoader(ForkedBooter.java:203) >> at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(For- kedBooter.java:155) >> at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter- .java:103) >> >> >> >> -- >> Lenjoy > > > > -- > Lenjoy > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > _________________________________________________ > Hsqldb-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/hsqldb-user ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 _______________________________________________ Hsqldb-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/hsqldb-user