cancel
Showing results for 
Search instead for 
Did you mean: 

Writing Query in Java UDF

Former Member
0 Kudos

Hi Experts,

I need help in writing query java UDF.

I receive Plant parameter as input to the UDF :

I want use this inbound parameter in my query, but I don't know how to write this :

1. Query = "SELECT * FROM TABLE WHERE F_VEHICLE_PRODUCTION_PLANT = ' :Plant ' " ;

Or

2. Query = "SELECT * FROM TABLE WHERE F_VEHICLE_PRODUCTION_PLANT'" +Plant +"'";

resultSet = accessor.execute(Query);  

Thanks for your help.

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member184720
Active Contributor
0 Kudos

"select * from table where F_VEHICLE_PRODUCTION_PLANT =" +"\'"+ Plant+ "\'";

But how are you executing this query? JDBC DML structure?

Former Member
0 Kudos

My Java UDF already exists and works fine. I'm connected to database by à CC JDBC Adapter :

channel   = LookupService.getChannel("MDM","CC_MDM_ORACLE_READ");                                                                                             
accessor  = LookupService.getDataBaseAccessor(channel);                                                                         

resultSet = accessor.execute(Query);

I just want to add this new condition to my query using parameter Plant.

OK, I will try with your exemple, thanks.

Former Member
0 Kudos

Hi,

Are you sure I need "/"  ? My query doesn't work.

Can I write this :

Query = "select * from table where F_VEHICLE_PRODUCTION_PLANT = '" + Plant+ "'";

former_member192851
Active Participant
0 Kudos

You need \ not /

Try with "

"select * from table where F_VEHICLE_PRODUCTION_PLANT = "+"\"" + plant + "\""

or with '

"select * from table where F_VEHICLE_PRODUCTION_PLANT = "+"\'" + plant + "\'"

Former Member
0 Kudos

I have a problem with my inbound argument.

I put traces in my UDF :

Why my argument is not recognized ? However this is a string...

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,


Why my argument is not recognized ? However this is a string...

Your argument is an array e.g String[] inp, but in your UDF I think you just used

inp.toString(); which would convert it into what you see above. To obtain the correct value, use its array position e.g to get first entry of inp[] array, it should be inp[0].toString();.

Regards,

Mark