[HELP] Getting "data exception: string data, right truncation" error

Suman Maity <[email protected]> Sun, 25 Mar 2018 20:59:24 +0530
Newsgroups gmane.comp.java.hsqldb.user
Message-ID <CAJTHOkhh8GbxkgFLu+y92S1QHtt9avNTCh4DHooOiXdN2+oGdw@mail.gmail.com>
Hi All,

I am trying to write Integration Test for my spring project using HsqlDB.
As I am using MySQL for production, I am using lots of MySQL in-built
function to manage the data like- *date_format*, *IF *etc. As
*date_format* function
is not present in HsqlDB, I wrote a simple SQL script to mock this. The SQL
script is given below.

CREATE FUNCTION DATE_FORMAT(TIMESTAMPSTRING TIMESTAMP, FORMAT CHAR)
  RETURNS VARCHAR(100)
  BEGIN ATOMIC
    RETURN cast(TIMESTAMPSTRING AS VARCHAR(100)) ;
  END;

 But when I am trying to use it like *SELECT DATE_FORMAT(now(), '%d/%b/%y')
*getting the following error

{DataIntegrityViolationException@6026} Method threw
> 'org.springframework.dao.DataIntegrityViolationException' exception.
>
>
>
>
>
>
>
>
> *detailMessage = "PreparedStatementCallback; SQL [SELECT
> DATE_FORMAT(now(), '%d/%b/%y')]; data exception: string data, right
> truncation" cause = {SQLDataException@6029} "java.sql.SQLDataException:
> data exception: string data, right truncation"  SQLState = "22001"
> vendorCode = -3401  next = null  detailMessage = "data exception: string
> data, right truncation"  cause = {HsqlException@6205}
> "org.hsqldb.HsqlException: data exception: string data, right truncation"
> stackTrace = {StackTraceElement[0]@6206}   suppressedExceptions =
> {Collections$UnmodifiableRandomAccessList@5972}  size = 0*


Any help will be appreciated. Thanks in advance.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Hsqldb-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hsqldb-user