ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » how to pass parameter for dynamic sql query in java compute

Post new topic  Reply to topic
 how to pass parameter for dynamic sql query in java compute « View previous topic :: View next topic » 
Author Message
Halloween
PostPosted: Fri Dec 11, 2015 12:22 pm    Post subject: how to pass parameter for dynamic sql query in java compute Reply with quote

Acolyte

Joined: 11 Mar 2015
Posts: 60

I am trying to execute this query

ResultSet results = stmt.executeQuery("select X.RETAIL_DATE as ORIGINAL_RETAIL_DT, X.RETAIL_TYPE AS ORIGINAL_RETAIL_TYPE, X.GREY_MARKET_IND as ORIGINAL_GREY_MKT_IND, a.RETAIL_DATE as LATEST_RETAIL_DT, A.RETAIL_TYPE AS LATEST_RETAIL_TYPE, case when a.CPO_RETAIL_IND < x'40' then ' ' when a.CPO_RETAIL_IND > x'F9' then ' ' else a.CPO_RETAIL_IND end AS LATEST_CPO_RETAIL_IND from mottretl a, mottretl X where a.serial_number = ? and A.BACKOUT_IND <> 'Y' and A.PROCESS_DATE = (select max(process_date) from mottretl b where b.serial_number = a.serial_number and BACKOUT_IND <> 'Y') and A.process_time = (select max(process_time) from mottretl c where c.serial_number = a.serial_number and BACKOUT_IND <> 'Y' and c.process_date = a.process_date) and X.SERIAL_NUMBER = A.serial_number and X.BACKOUT_IND <> 'Y' and X.PROCESS_DATE = (select MIN(process_date) from mottretl Y where Y.serial_number = X.serial_number and BACKOUT_IND <> 'Y') and X.process_time = (select MIN(process_time) from mottretl Z where Z.serial_number = a.serial_number and BACKOUT_IND <> 'Y' and Z.process_date = X.process_date)");



I am trying to pass the parameter in place of ? in sql query statement.
Should i be like use + and then pass the parameter?[/b]
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Dec 11, 2015 12:33 pm    Post subject: Re: how to pass parameter for dynamic sql query in java comp Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Halloween wrote:
Should i be like use + and then pass the parameter?


No.

The documentation shows that method takes a String. So you need to build the String with the parameter in place, then pass the String to the method.

This is what you get for deciding to use a JCN rather than one of the inbuilt nodes. IIB won't do any of the heavy lifting for you; it's all on your code.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Dec 11, 2015 2:06 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

You should be using following

Code:
PreparedStatement ps = connection.PreparedStatement (mysql);
ps.setStringParameter(1, thestring);
rs = ps.executeQuery()

Hope that helps.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » how to pass parameter for dynamic sql query in java compute
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.