#1 2012-05-21 17:54:28

BenoitB
Member
Registered: 2012-05-14
Posts: 47

Compilation problem

Tags: [date, error]

Hi,

I would like to make work this code below in the Tmap component, could you tell me how to do i'm actually stuck.

(row1.Code_acte ==row2.Code)?TalendDate.compareDate(row2.DateActe,row1.Datedebut,"dd-MM-yyyy"):null 

If the code are equals, i want to compare 2 dates, if not i want nothing to be done.

Thanks for your help !

Offline

#2 2012-05-21 18:45:00

phobucket
Member
Company: Knoetry
Registered: 2010-07-27
Posts: 146
Website

Re: Compilation problem

Hi Benoit,

What do you want to return? 
Are the Code_acte and Code numeric or string?  If they are strings, use row1.Code_acte.equals(row2.Code) instead of ==

You may want to add a check to see if row1.Code_acte is null to help avoid NPEs.

null != row1.Code_acte?(row1.Code_acte.equals(row2.Code)?TalendDate.compareDate(row2.DateActe,row1.Datedebut,"dd-MM-yyyy"):null):null

compareDate returns and integer (-1, 0 or 1).  Does your ouput field allow for nulls?

Thanks,
Ben

Offline

#3 2012-05-22 09:11:29

BenoitB
Member
Registered: 2012-05-14
Posts: 47

Re: Compilation problem

Ok, first thanks for your solution.

Code_acte and code are numeric, that's why I use ==

How could I know if my output fileds allows null value ? (=>Except for the primary key, they are all nullable)

Even if i transform Code_acte and code in string, I still have my compilation problem, and it doesn't tell me more than "Exception in thread main java.lang.error: compilation pb non resolved"

I rly don't see where is the mistake, I'm actually testing several expressions to check what I can do/cannot do, but if sbdy knows more, it will help !

Thanks for your help

Offline

#4 2012-05-22 09:51:11

BenoitB
Member
Registered: 2012-05-14
Posts: 47

Re: Compilation problem

After a few test i know that my date field aren't good because i cannot use the compareDate function,

When I test TalendDate.compareDate(row2.DateActe,row1.Datedebut,"dd-MM-yyyy") i've got the same message "Exception in thread..." WHY ??

Datedebut, type: Date, nullable, model "dd-MM-yyyy" length: 26
DateActe, type: Date, nullable, model "dd-MM-yyyy" length: 26

The files used come from AccessInput.

Thanks for your help !

Offline

#5 2012-05-22 10:23:36

BenoitB
Member
Registered: 2012-05-14
Posts: 47

Re: Compilation problem

After a new serie of test, i can tell you that the test button in the TMap component doesn't work correctly, when I execute the job it works (just with compareDate) and when I test the expression in the Tmap it still tells me "Exception in thread..."

So the test button doesn't work -_-

Offline

#6 2012-05-22 17:12:29

phobucket
Member
Company: Knoetry
Registered: 2010-07-27
Posts: 146
Website

Re: Compilation problem

Well, better the job works and the test button doesn't than the other way around...haha.  Sounds like a bug ticket.

Offline

#7 2012-05-22 17:17:07

janhess
Member
Company: Newcastle University
Registered: 2009-05-19
Posts: 1121

Re: Compilation problem

I don't think it's ever worked properly.

Offline

#8 2012-05-22 17:44:02

BenoitB
Member
Registered: 2012-05-14
Posts: 47

Re: Compilation problem

Ok, but do you happen to know how could I program what i want in the 1st message, cause I still can't make it work, now i've got a null pointer exception, I'm trying to avoid it but I think data processing will last too long.

Thanks for your help !

Offline

#9 2012-05-22 20:01:17

phobucket
Member
Company: Knoetry
Registered: 2010-07-27
Posts: 146
Website

Re: Compilation problem

Is you NPE pointing to this expression, or is the problem that the output field does not allow nulls?

You could check all input params for null first.

(null != row1.Code_acte && null != row2.DateActe && null != row1.Datedebut) ?(row1.Code_acte.equals(row2.Code)?TalendDate.compareDate(row2.DateActe,row1.Datedebut,"dd-MM-yyyy"):null):null

Offline

#10 2012-05-23 09:59:19

janhess
Member
Company: Newcastle University
Registered: 2009-05-19
Posts: 1121

Re: Compilation problem

(row1.Code_acte ==row2.Code)
If these are strings use (row1.Code_acte.equals(row2.Code))

Offline

#11 2012-05-23 10:08:27

BenoitB
Member
Registered: 2012-05-14
Posts: 47

Re: Compilation problem

Hi

I can't fix this damn NPE, all my fields allow null, but then it still doesn't work.

The problem is due to an exeption in component tAccessOutput_1, but I see nothing wrong in it.

So what does mean this error message, something wrong with my Tmap component or with my tAccessOutput ?

Thanks for your help !

Offline

#12 2012-05-23 10:12:43

janhess
Member
Company: Newcastle University
Registered: 2009-05-19
Posts: 1121

Re: Compilation problem

Have you clicked on the code tab to see what it's doing at the line that generates the npe?

Sorry missed the bit about the codes being numeric.

Offline

#13 2012-05-23 10:55:58

BenoitB
Member
Registered: 2012-05-14
Posts: 47

Re: Compilation problem

Sorry but how can i know the line that generate the NPE, my message error is this one :

Exception in component tAccessOutput_1
java.lang.NullPointerException
    at projetlocal.testcodeacte2_0_1.TestCodeActe2.tAccessInput_1Process(TestCodeActe2.java:1240)
....

Can't find my mistake, action on table weither it's create nor drop if it exist and create doesn't change anything. Id I edit the schem and change the type of my data, the error message changes, it becomes and ODBC exception.

Thanks for your help !

Offline

#14 2012-05-23 11:01:01

janhess
Member
Company: Newcastle University
Registered: 2009-05-19
Posts: 1121

Re: Compilation problem

line 1240?

Offline

#15 2012-05-23 11:08:48

BenoitB
Member
Registered: 2012-05-14
Posts: 47

Re: Compilation problem

And where can I find this code ?

Offline

#16 2012-05-23 12:19:56

janhess
Member
Company: Newcastle University
Registered: 2009-05-19
Posts: 1121

Re: Compilation problem

Select the code tab as I said before.

Offline

#17 2012-05-23 15:35:32

phobucket
Member
Company: Knoetry
Registered: 2010-07-27
Posts: 146
Website

Re: Compilation problem

At the bottom left of the workspace window (where you create the jobs), but above the Context/Code/Run/etc tabs, there is a small tab labeled "code".

Offline

#18 2012-05-23 15:52:38

BenoitB
Member
Registered: 2012-05-14
Posts: 47

Re: Compilation problem

Yes I saw it after a while -_-

I'm still trying to solve it !

Offline

Board footer

Powered by FluxBB