문제

Good morning to everybody.

I have an issue with using MEL Expression in a JDBC ORACLE database query.

In particular the Mule flow accepts a Excel file that is transformed in a Map through a Datamapper and its fields are used to make a query in a database in this form:

<jdbc-ee:query key="Fill Table" value="INSERT INTO BUFF_SBIL_ZONALE (DATA_ORA,MACRO_ZONA,SEGNO_SBIL,PRZ_MSD_VEN,PRZ_MSD_ACQ,ID_BIS,FILE_NAME,DATA_LOAD)                                                 
VALUES (TO_DATE(#[map-payload:DATA_ORA], 'DD/MM/YYYY  hh:mi:ss'),#[map-payload:MACROZONA],#[map-payload:SEGNO],#[map-payload:P_medioMSD_VEN],#[map-payload:P_medioMSD_ACQ],#[message.inboundProperties['correlationId']],#[message.InvocationProperty['originalFilename']],SYSDATE)"/>

The query seems correct but when I execute the application, I receive an exception that advice me that #[map-payload:P_medioMSD_VEN] is NULL (correctly, because in the Excel file it does not exist) and the MEL Expression cannot read a NULL value. The problem, so, is not a SQL issue but a MEL issue that does not accept a NULL database field value.

Does anybody know how to bypass the MEL Exception in order to accepts the mullable value?

Thanks in advance to everybody

The exception thrown is: *org.mule.api.expression.RequiredValueException: Expression Evaluator "bean" with expression "xy" returned null but a value was required. *

도움이 되었습니까?

해결책

I found the solution. I'll write here just for someboby that will have the same problem.

If you want to make a MEL expression value optional (i.e. a NULL value is a right value), you should write a '?' at the end of a MEL expression.

#[map-payload:P_medioMSD_ACQ?]

Putting a '?' the value is optional and a NULL value is accepted

다른 팁

Before passing them to MEL, check if fields are NOT NULL. If you know certain fields will always be NULL, don't specify it in insert query at all, it will get default value of NULL in db

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top