1

all, what is equivalent for TO_CHAR and LTRIM of Oracle in H2 or Java?

I have select statements like this :

select LTRIM(TO_CHAR(colone,'009')) from Table;

I want equivalent to make the treatment in java side.

Thanks in Advance.

CHARAFI Saad
  • 1,340
  • 3
  • 16
  • 36
  • Db2 has both TO_CHAR and LTRIM (on all platforms, synonym of VARCHAR_FORMAT). – mao Aug 28 '18 at 13:54
  • Here is a possible answer you want in Java. https://stackoverflow.com/questions/15567010/what-is-a-good-alternative-of-ltrim-and-rtrim-in-java – PJAutomator Aug 28 '18 at 13:57
  • @mao Thank you for ur reply, I wanted to write H2 but I would like to do java-side processing to be dependent on the database – CHARAFI Saad Aug 28 '18 at 13:59
  • 1
    `String.trim()` and `SimpleNumberFormat()` –  Aug 28 '18 at 14:02
  • I'd expect something like `String.format("%03d", colone)`. I don't see any reason to strip of the leftmost whitespace if no whitespace is produced by the format string. To the DB aficionados: is there any difference between specifying `000` and `009` as format string for `TO_CHAR`, because I don't see it. – Maarten Bodewes Aug 28 '18 at 14:21
  • H2 has both functions. See http://www.h2database.com/html/functions.html – Ritesh Aug 28 '18 at 14:47

0 Answers0