alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

HSQLDB example source code file (TestSelfFieldLimits.txt)

This example HSQLDB source code file (TestSelfFieldLimits.txt) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - HSQLDB tags/keywords

decimal, decimal

The HSQLDB TestSelfFieldLimits.txt source code

-- field limit tests
-- works fully with sql.enforce_strict_size
-- from 1.8.0.RC9 DECIMAL precision and scale is enforced
-- when scale is specified, all input is rounded down to the relevant scale
-- precision is then enforced on the result of rounding down
drop table flimit if exists;
create table flimit (charf1 character(4), vcharf1 varchar(4), decf1 decimal(10,2));
insert into flimit values('one', 'two', 10.2);
/*r
 one ,two,10.20
*/select * from flimit;
/*u1*/delete from flimit;
/*e*/insert into flimit values('twenty', 'two', 10.2);
/*e*/insert into flimit values('one', 'twenty', 10.2);
insert into flimit values('one', 'two', 99999999.11111);
/*r
 one ,two,99999999.11
*/select * from flimit;
/*r
 one ,two,99999999.11
*/select * from flimit where charf1 in('one','two');
/*r
 one ,two,99999999.11
*/select * from flimit where charf1 in('one   ','two');
/*r
 99999999
*/select cast(decf1 as numeric(8)) from flimit;
/*r
 99999999.1100
*/select cast(decf1 as numeric(12,4)) from flimit;
/*r
 one tw,tw
*/select cast((charf1 || vcharf1) as varchar(6)), cast(vcharf1 as varchar(2)) from flimit;
/*e*/insert into flimit values('one', 'two', 999999999.11);
/*e*/insert into flimit values('one', 'two', cast(999999999.11111 as decimal(10,2));
drop table flimit;
create table flimit (a timestamp(0), b timestamp(6), c timestamp);
insert into flimit values('2005-05-21 10:10:10.123456','2005-05-21 10:10:10.123456','2005-05-21 10:10:10.123456');
/*c0*/select * from flimit where a = b;
/*c0*/select * from flimit where a = c;
/*c1*/select * from flimit where b = b;

Other HSQLDB examples (source code examples)

Here is a short list of links related to this HSQLDB TestSelfFieldLimits.txt source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.