
Anonymous
Not applicable
2014-05-22
12:55 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[resolved] Need help with "Invalid character constant" error, etc.
Hi, here is my tMap expression:
Getting an "invalid character constant" error on this
column_x is of data type short and I'm wanting to change it to string
Occasionally my source system gives a value of '0000'
Note: The source table column is actually of MySQL data type year by the way, but I'm just calling it a short in Talend; if this is a part of my problem then I welcome solutions
The reason for all the dancing around is that Java doesn't accept a year of '0000' as a valid Java date, which is why I thought to try a short, but it seems the '0000' was still causing problems
Thanks for any advice
table_a.column_x == 0000 ? 'UNK' : String.valueOf(table_a.column_x)
Getting an "invalid character constant" error on this
column_x is of data type short and I'm wanting to change it to string
Occasionally my source system gives a value of '0000'
Note: The source table column is actually of MySQL data type year by the way, but I'm just calling it a short in Talend; if this is a part of my problem then I welcome solutions
The reason for all the dancing around is that Java doesn't accept a year of '0000' as a valid Java date, which is why I thought to try a short, but it seems the '0000' was still causing problems
Thanks for any advice
1,192 Views
1 Solution
Accepted Solutions

Anonymous
Not applicable
2014-05-26
12:54 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
"0000" should also to be a String to keep 'precision' (4 digits) .
Convert it with tconvert before expression.
regards
laurent
table_a.column_x.equals("0000") ? "UNK" : table_a.column_x
"0000" should also to be a String to keep 'precision' (4 digits) .
Convert it with tconvert before expression.
regards
laurent
1,192 Views
8 Replies

Anonymous
Not applicable
2014-05-23
12:19 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I would like to read it as a string, and then check the string if it contains "0000", if so, set it to null or other value, if not, parse the string to Date if needed.
Shong
I would like to read it as a string, and then check the string if it contains "0000", if so, set it to null or other value, if not, parse the string to Date if needed.
Shong
1,192 Views

Anonymous
Not applicable
2014-05-23
04:18 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not sure, but the error is referring to 'UNK' as invalid char constant !!!
What is datatype of your output column?
Vaibhav
What is datatype of your output column?
Vaibhav
1,192 Views

Anonymous
Not applicable
2014-05-23
12:11 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In Java single quotes indicate a Char, double quotes for String. 'UNK' is not a valid Char. 'U' is a valid Char. "UNK" is a valid String.
1,192 Views

Anonymous
Not applicable
2014-05-26
12:54 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
"0000" should also to be a String to keep 'precision' (4 digits) .
Convert it with tconvert before expression.
regards
laurent
table_a.column_x.equals("0000") ? "UNK" : table_a.column_x
"0000" should also to be a String to keep 'precision' (4 digits) .
Convert it with tconvert before expression.
regards
laurent
1,193 Views

Anonymous
Not applicable
2014-05-26
03:03 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok thanks very much for all of these ideas, I'll mark the thread resolved
1,192 Views

Anonymous
Not applicable
2014-05-27
01:27 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
What was the problem and how you solved it, could you pl explain it here?
Thanks
Vaibhav
What was the problem and how you solved it, could you pl explain it here?
Thanks
Vaibhav
1,192 Views

Anonymous
Not applicable
2014-05-27
01:45 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I ended up changing it back to a short/smallint, saved some bytes that way in my DB
However, kzone's answer looks reasonable, though I didn't try it ... did it not work for you?
However, kzone's answer looks reasonable, though I didn't try it ... did it not work for you?
1,192 Views

Anonymous
Not applicable
2014-05-28
06:30 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
However, kzone's answer looks reasonable, though I didn't try it
arhhgghhh ... Damned
1,192 Views
