SOURCING10: Passing parameters to a Query Based webservice using JAVA

Hi Experts,
I have been working on consuming a Query based webservice published in Souricng10 in a simple JAVA class. The query has a filter parameter which is not mandatory. I am able to consume the webservice using the GET method and display the content of the webservice. But when i try to POST a value to the filter parameter of the query i am getting the following error:
java.io.IOException : Server returned HTTP response code: 415 for URL: http://sapcild9.web.bc:55000/sourcing/ngservices/rest/query/Z_TEST_WS_QUERY/execute/
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
Following is the code which i have used:
   URL url = new URL("http://sapcild9.web.bc:55000/sourcing/ngservices/rest/query/Z_TEST_WS_QUERY/execute/");
   HttpURLConnection connection = (HttpURLConnection)url.openConnection();
   connection.setRequestProperty("Authorization", "Basic " + authStringEnc);
   connection.setRequestProperty("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
   connection.setRequestProperty("Content-Length", "" +Integer.toString(urlParameters.getBytes().length));
   connection.setRequestProperty("Content-Language", "en-US");
   connection.setUseCaches (false);
   connection.setDoInput(true);
   connection.setDoOutput(true);
   connection.setAllowUserInteraction(true);
   connection.setInstanceFollowRedirects(false);
   connection.setRequestMethod("POST");
   connection.connect();
   //Send request
   OutputStream out = connection.getOutputStream();
   OutputStreamWriter wr= new OutputStreamWriter(out, "UTF-8");
   wr.write("EXTERNAL_ID");
   wr.write("=");
   wr.write(URLEncoder.encode("temp","UTF-8"));
   wr.close();
   out.close();
   is = connection.getInputStream();
   isr =new InputStreamReader(is);
   BufferedReader bufferReader = new BufferedReader(isr);
   String str; StringBuffer stringBuffer = new StringBuffer();
   while ((str = bufferReader.readLine()) != null) {
   stringBuffer.append(str);
   stringBuffer.append("\n");
   System.out.println(stringBuffer.toString());
   connection.disconnect();
   is.close();
Please Advise how to proceed on this isssue?
Thanks in advance.
Srikanth Emani

Hi Gael,
your URL is made up of :
[ProcedureName]?[parameter1]=[value1]&[parameter2]=[value2]
creating URLs like this can have problems especially with spaces and punctuation.
the answer is a FORM
the following will create a hidden form :
FORM ACTION="[ProcedureName]" METHOD="POST" name="F1"
INPUT type="HIDDEN" name="[parameter1]" value="[value1]"
INPUT type="HIDDEN" name="[parameter2]" value="[value2]"
/FORM
you can set the values in the form using:
document.F1.[parameter1].value="abc123%%&&$$!";
document.F1.submit();
will submit the form and the PL/SQL procedure should receive the text as it was contained in the form.
the only characters that can now cause problems are :
" as it delimits the field.
' as it may cause problems in PL/SQL.
\ as it is a special character.
Regards Michael

Similar Messages

  • Does XML approach for passing parameters in the query make the query slow?

    Hi,
    I am using XML approach for passing parameters in a query. This is running very slow but when I pass comma separated values in parameter, it runs very fast.
    So it concludes that we should not use XML approach for passing parameters. Please confirm me that Am I right or wrong?
    I have also googled to clear my doubt but not get solution till now. please help me.
    Regards,
    Sachin

    914014 wrote:
    Hi,
    I am using XML approach for passing parameters in a query. This is running very slow but when I pass comma separated values in parameter, it runs very fast.
    So it concludes that we should not use XML approach for passing parameters. Please confirm me that Am I right or wrong?
    I have also googled to clear my doubt but not get solution till now. please help me.
    Regards,
    SachinShow us what you are doing, create a simple yet complete example we can run on our Oracle instances.
    Then we will know exactly what you mean, and can comment appropriately.
    Cheers,

  • How to create Webservice using java

    Hi Experts,
          I am very new to Visual composer, can any one of you suggest how to create a webservice using java so that i can use that webservice in Visual Composer application.If it is possible please give me detailed description about it.
    Regards,
    Prasanna.

    Hi Prasanna,
    See if my article is of any use to you:
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/b00917dc-ead4-2910-3ebb-b0a63e49ef10">How to Create a Web Service using an Enterprise JavaBean</a>
    For creating Web Services, you won't need to do the MS SQL Part explained in my doc. You can just concentrate on the part where i explain how to create a Web Service using an EJB.
    Bye
    Ankur

  • Developing webservices using Java SE6 and Tomcat Webserver

    Hi All,
    I am trying to develop a webservice using Java SE6 Beeta SDK with Tomcat webserver. I read somewhere in the Sun site and it says JAXWS2.0 is fully packaged with JAVA SE 6 SDK? If this is correct then what are all the remining packages(jar files present in JWSDP2.0) required to develop and publish the webservice.
    I does the setup as follows.
    - Install the Java SE6 SDK Beeta available.
    - Install Tomcat 5.17 webserver.
    - Started the webserver by setting java_home as SDK6.
    I am not able to publish the webservice with this setup
    Do i need to place any other package present in JWSDP2.0 in Tomcat_home/common/lib ?
    I used the same example present in JWSDP2.0 package.
    Please guide me regarding this?
    Thanks In Advance,
    Mohan

    Any ideas on how this could be achieved.Have you looked at the Unofficial Web Start FAQ at the Lopica site?
    - Gerald
    PS: You might wonna also consider posting your question to the Java Web Start developers group at Yahoo! See http://groups.yahoo.com/group/webstart

  • Passing parameters for a query throught XML and capturing response in the same

    Hi All,
    I have defined a RequestParameters object and i am passing paramerts for a query through XML and trying to capture the result in the same and send back to the source. In this case i am send XML from excel.
    Below is my XML format.
    <?xml version="1.0" encoding="utf-8"?>
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Insert xmlns="http://tempuri.org/">
    <dataContractValue>
    <dsRequest>
    <dsRequest>
    <SOURCE></SOURCE>
    <ACTION>Insert</ACTION>
    <RequestParams>
    <RequestParams>
    <ACC_NO>52451</ACC_NO>
    <EMP_CITY>HYD</EMP_CITY>
    <EMP_NAME>RAKESH</EMP_NAME>
    <EMP_CONTACT>99664</EMP_CONTACT>
    <EMP_JOM>NOV</EMP_JOM>
    <EMP_SALARY>12345</EMP_SALARY>
    </RequestParams>
    <RequestParams>
    <ACC_NO>52452</ACC_NO>
    <EMP_CITY>HYD</EMP_CITY>
    <EMP_NAME>RAKESH</EMP_NAME>
    <EMP_CONTACT>99664</EMP_CONTACT>
    <EMP_JOM>NOV</EMP_JOM>
    <EMP_SALARY>12345</EMP_SALARY>
    </RequestParams>
    </RequestParams>
    </dsRequest>
    <dsRequest>
    <SOURCE></SOURCE>
    <ACTION>Update</ACTION>
    <RequestParams>
    <RequestParams>
    <ACC_NO>52449</ACC_NO>
    <EMP_CITY>HYD1</EMP_CITY>
    <EMP_NAME>RAKESH1</EMP_NAME>
    <EMP_SALARY>1345</EMP_SALARY>
    </RequestParams>
    <RequestParams>
    <ACC_NO>52450</ACC_NO>
    <EMP_CITY>HYDer</EMP_CITY>
    <EMP_NAME>RAKEH</EMP_NAME>
    <EMP_SALARY>1235</EMP_SALARY>
    </RequestParams>
    </RequestParams>
    </dsRequest>
    </dsRequest>
    </dataContractValue>
    </Insert>
    </s:Body>
    </s:Envelope>
     Where i have a List of dsRequest and RequestParams, where i can send any number of requests for Insert,Update. I have two a XML element defined in RequestParams "RowsEffected","error" where the result will be caputred and is updated
    to the response XML.
    I have 6 defined in RequestParams
    EMP_SALARY(int),ACC_NO(int),EMP_CITY(string),EMP_NAME(string),EMP_CONTACT(string),EMP_JOM(string)
    My Question is:
    When i am trying to build response XML with the following code, the parameters which are not given in the Request XML are also appearing in the Response.
                    ResponseParams.Add(
    newdsResponse()
                        ACTION = OriginalParams[a].ACTION,
                        SOURCE = OriginalParams[a].SOURCE,
                        Manager = OriginalParams[a].Manager,
                        RequestParams = OriginalParams[a].RequestParams
    Where the OriginalParams is dsRequest
    Ex: In my update query i will only send three parameters, but in my response building with ablove code, i am getting all the variables defined as INT in the RequestParameters.
    Is there any way i can avoid this and build response with only the parameters given in the Request ??
    Appreciate ur help..Thanks
    Cronsey.

    Hi Kristin,
    My project is, User will be giving the parameters in the excel, and using VBA, the values are captured and an XML is created in the above mentioned format and is send to web service for the Insert/Update.
    I created a webservice which reads the values from <datacontract> and it consist of list of <dsRequests> where any number of Insert/Upate commands can be executed, with in which it contains a list of <RequestParams> for multiple insertion/Updation.
    //function call
    OriginalParams = generator.Function(query, OriginalParams);
    where OriginalParams is List<dsRequest>
    //inside function
    command.Parameters.Add()// parameters adding
    int
    val = command.ExecuteNonQuery();
    after the execution,an XML element is added for the response part.and it is looped for all the RequestParams.
    OriginalParams[i].Result.Add(
    newResult()
    { ERROR = "No Error",
    ROWS_EFFECTEFD = 1 });
    //once all the execution is done the response building part
    for(inta
    = 0; a < OriginalParams.Count; a++)
                    ResponseParams.Add(
    newdsResponse()
                      Result = OriginalParams[a].Result
    QUEST: When i am trying to build response XML with the following code, the parameters which are not given in the Request XML are also appearing in the Response.
    Ex: In my update query i will only send three parameters, but in my response building with ablove code, i am getting all the variables defined as INT in the RequestParameters.
    Is there any way i can avoid this and build response with only the parameters given in the Request ??
    Appreciate ur help..Thanks
    Cronsey.

  • Passing parameters to select query in DB link from invoke...

    I am having a DB partner link which executes the select query based on user specified parameter.
    Now i have created an invoke activity and specified input[this needs to be passed to query] and output parameters[this is query result]. This invoke activity calls DB partner link in which one parameter has been created to be used in select query. So my doubt is , will DB partner link take up the input parameter of invoke activity automatically or do we need to specify any mapping for this?

    When you create a db partnerlink the parameter you create for your select is the input and when you create the input variable in the invoke for this partnerlink it is created with the right type for the parameter.
    Create an Assign before your invoke and assign a value to the input variable you created in the invoke. That value will be passed and used as the parameter in the select.
    Heidi.

  • Passing parameters to oracle query

    Hi Everyone,
    I'm a newbie to oracle and need help passing parameters to an oracle query. For example, I need to show all the employees in a certain department.So a list of "DEPT_CODE"'s will be displayed on a webpage and then the selected value will be passed to the query. I currently have this query in MS Access and use the bracket for user input ("[Dept]"). But how can this be done in oracle?
    I am using ASP.NET 2.0 and Crystal Reports XI. Basically I have a webform where users can select the date range and department from a listbox. When the submit button is clicked, the values are passed to the query in crystal reports. For example, I have a query with "DEPT" as a parameter. So I pass the value of the selected listbox item from the webform to the crystal report. But now I have to select data from an oracle database and provide parameters. This is where I need help.
    Thanks in advance
    -Sam

    Duplicate post.
    Refer to this thread
    Passing parameters to oracle query

  • How to pass parameters to Xacute Query

    hai all,
               Can we pass parametes to Xacute Query using java script with out using any applet in the page..
    Thanks,
    Vidhya

    Hi Vidhya,
    use this function
    service.useService(http://"hostname"/Lighthammer/Illuminator?QueryTemplate=Querytemplatpath&Content-Type=text/xml&Param.1=Param",_"Service1");
    Hope That helps,
    Regards,
    Musarrat
    Edited by: Musarrat Husain on Mar 4, 2008 2:22 PM

  • Developing SOAP based Webservice using Axis 2 Eclipse plugin

    Hi,
    I want to develop a SOAP based Webservice which connects to the PostgreSQL DB , by fetching the data for the employeeId entered and display the results in the browser. I'm using using JDK 1.6, Tomcat 6.0, Axis 2.0 , with Axis 2 Eclipse Plugin. Please send me a sample code of how to build it, i am able find some examples on the internet, but none of them are related to connecting to the DB and fetching the data. It will be great if you guys can provide the sample application which does have the same functionality as mine. Please do respond as this is urgent. Thanks in advance..
    Thanks,
    Rithu

    Thanks Adhir Mehtaji, This is what i have come up with, developing a webservices based on SAAJ and deploying that in Tomcat server, here is the Webservice and the other related files:-
    public class EmployeeService {
         * This method returns the Employee Name
         * @param empId String
         public void getEmployeeName(SOAPEnvelope req, SOAPEnvelope resp) throws javax.xml.soap.SOAPException {
              System.out.println("Inside the getEmployeeName in Employee Service");
              IEmployeeDAO employeeDAO= null;
              employeeDAO = new EmployeeDAOImpl();
              SOAPBody body = resp.getBody();
              String empId = null;
              NodeList empIdNodeList = req.getBody().getElementsByTagName("empId");
              for( int i=0; i < empIdNodeList.getLength(); i++ ) {
                   Element empIdElementElement = (Element) empIdNodeList.item(i);
                   Node empIdNode = empIdElementElement.getChildNodes().item(0);
                   empId = empIdNode.getNodeValue();
                   System.out.println("the empId in the employee service is:::"+empId);
              addNode(body,"empName",employeeDAO.getEmployeeName(empId));
              //addNode(body,"segmentName1",custSegmentDAO.getSegmentName(ZipCode));
         private static void addNode(SOAPBody body,String nodeName,String nodeValue) throws SOAPException{
              body.addChildElement(nodeName).addTextNode(nodeValue);
         This Service is exposed as a Webservice which connects to the DAO and get the response for the EmpId.
         This is the client file:-
         public class GetEmployeeNameClient {
              public static void main(String[] args) throws Exception {
                   // Invoking the Webservice endpoint which is hosted (deployed) in Tomcat by passing the SOAP Message request
                   // Get the SOAP Message response , which contains the employee name for the empId 100
                   // Parse the SOAP Message response to get the employee name (response from the WS)
                   String[] nodeNames = { "empId" };
                   String[] nodeValues = { "100" };
                   SOAPMessage message = GetEmployeeNameClient.getMessageFactory(
                             "getEmployeeName", nodeNames, nodeValues);
                   SOAPConnection conn = SOAPConnectionFactory.newInstance()
                             .createConnection();
                   SOAPMessage response = conn.call(message,
                             "http://localhost:8080/axis/services/EmployeeService");
                   // If the response is not null then everything is fine with the WS.
                   System.out.println("the response is what???"+response);
                   System.out.println("\n Soap response:\n");
                   System.out.println("\nXML response\n");
                   // Create transformer
                   TransformerFactory tff = TransformerFactory.newInstance();
                   Transformer tf = tff.newTransformer();
                   // Get reply content
                   Source sc = response.getSOAPPart().getContent();
                   // Set output transformation
                   StreamResult result = new StreamResult(System.out);
                   tf.transform(sc, result);
                   System.out.println();
                   // For these to work we need to connect to the DB - jdbc:oracle:thin:@ora-b2cd:6473:b2cd to get the segment name
                   SOAPBody soapBody = response.getSOAPBody();
                   System.out.println("the soapBody is what???"+soapBody);
                   NodeList empNameNodeList = soapBody.getElementsByTagName("empName");
                   System.out.println("the empNameNodeList.getLength is::"+empNameNodeList.getLength());
                   for (int i = 0; i < empNameNodeList.getLength(); i++) {
                        System.out.println("inside the loop");
                        Element empNameElement = (Element) empNameNodeList.item(i);
                        System.out.println("the empNameElement is what???"+empNameElement);
                        Node empNameNode = empNameElement.getChildNodes().item(0);
                        System.out.println("the empNameNode is what???"+empNameNode);
                        System.out.println("Employee Name For empId is ...... "
                                  + empNameNode.getNodeValue());
              // Construct the SOAP Message request by passing the empId 100(should come from UI)
              private static SOAPMessage getMessageFactory(String methodName,
                        String[] nodeNames, String[] nodeValues) throws SOAPException {
                   SOAPMessage message = null;
                   try {
                        System.out.println("Inside the getMessageFactory");
                        MessageFactory messageFactory = MessageFactory.newInstance();
                        message = messageFactory.createMessage();
                        SOAPPart soapPart = message.getSOAPPart();
                        SOAPEnvelope envelope = soapPart.getEnvelope();
                        SOAPBody body = envelope.getBody();
                        SOAPElement bodyElement = body.addChildElement(envelope
                                  .createName(methodName));
                        for (int index = 0; index < nodeNames.length; index++) {
                             bodyElement.addChildElement(nodeNames[index]).addTextNode(
                                       nodeValues[index]);
                        message.saveChanges();
                        // View input
                        System.out.println("\n Soap request:\n");
                        message.writeTo(System.out);
                        System.out.println();
                   } catch (Exception e) {
                        e.printStackTrace();
                   return message;
         This client will send a SOAPMessage with EmpId (100) as a request and get the response from the Webservice as SOAPMessage , which
         contains the empname for the respective empid which is passed.
    I tested this service in the browser, it is up and running through the URL : http://localhost:8080/axis/services
    But when i try to access the webservice to get the response from my client program, i am getting the following SOAP Fault string:-
    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body><soapenv:Fault>
    <faultcode>
    soapenv:Server.userException
    </faultcode>
    <faultstring>
    org.xml.sax.SAXNotRecognizedException: Feature: http://xml.org/sax/properties/lexical-handler
    </faultstring>
    <detail>
    <ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">
    user-15bbc0db6e
    </ns1:hostname>
    </detail>
    </soapenv:Fault>
    </soapenv:Body>
    </soapenv:Envelope>
    My client path contains :-
    axis.jar;
    jaxrpc.jar;
    saaj.jar;
    commons-logging.jar;
    commons-discovery.jar;
    wsdlj4.jar;
    axis-ant.jar;
    log4j-1.2.4.jar
    xerces.jar
    activation.jar
    mail.jar
    Similary the in the d:/tomcat/webapps/axis/WEB-INF/lib,contains the same as that in client path.
    I am using Tomcat 6.0 , JDK 1.6, I have googled and found that the expection is due to "Xerces.jar" not in Tomcat/webapps/axis/WEB-INF/lib.
    I have copied xerces.jar in the said path, still the error persists. Please do provide a solution to this. Where i have gone wrong.
    I have one more query, If i have to rest a "list" as a response from the server (webservice), how i can add the list into the SOAPMessage? Whether i need to parse it and add the values one by one in the SOAPMessage? like
    <empname> xxxx</empname> <empage>25</empage>
    <empname> yyyy</empname> <empage>26</empage>
    Please answer these queries.
    Thanks,
    Rithu

  • Securing REST based Webservices using OSB

    Can anyone please lead me to any pointers on securing the REST based webservices.
    Thanks,
    KC

    REST is more or less, a pure HTTP service so it is as secure as that. From my perspective transport security (basic authentication, SSL) is the basic security requirement for a REST based web-service. As far as message security is concerned, you may use custom HTTP headers to pass the tokens/digest but again it requires transmission over SSL to become an effective solution.
    If you really have tight requirement from message security perspective, then I would suggest going to SOAP rather than using REST.
    Regards,
    Anuj

  • Parameter Passing to Subreport Database Command in CR2008 using java

    Hi
    In subreport i have  a query which accept parameter from the parameter list and works fine in crystal report designer but using java when i am trying to pass the parameter form it gives me error ERROR java.lang.nullpointer Exception. Below is the code attached to send parameter to subreport.
    oReportClientDocument = new ReportClientDocument ();
                oReportClientDocument.open ( strRepPath, 0 );
                reportSource = oReportClientDocument.getReportSource ();
                oCrystalReportViewer = new CrystalReportViewer ();
                oCrystalReportViewer.setOwnPage ( true );
                oCrystalReportViewer.setOwnForm ( true );
                oCrystalReportViewer.setDisplayGroupTree ( false );
                oCrystalReportViewer.setDisplayToolbar ( true );
                oCrystalReportViewer.setPrintMode ( CrPrintMode.PDF );
              if ( fields != null )
                    oFields = new Fields ();
                    if ( !fields.isEmpty () )
                        o = null;
                        i = null;
                        o = new Object ();
                        i = fields.keySet ().iterator ();
                        while ( i.hasNext () )
                            o = i.next ();
                             setParamaterFields ( oFields, o.toString (), fields.get ( o ) );
                    oCrystalReportViewer.setParameterFields ( oFields );

    Hi David,
    I guess you already have the parameters in the Main report.
    Create a formula called Start_Date:
    Min({?Date_Parameter})
    Create another formula called End_date:
    Max({?Date_Parameter})
    Next, insert the sub-report with Order details table as the datasource.
    Then, right-click the subreport and select Change Subreport Links > Move the Start_date formula and End_date to the 'Fields to link to' area and make sure you uncheck the option 'Select data in subreport based on field' for both of them.
    Then, you also wish to link Salesman_Id, so move this field to the 'Fields to link to' area and from the drop-down for 'Select data in subreport based on field' select the Salesman_ID from the sub-report.
    Now, right-click the sub-report and select Edit subreport. The design page of the Subreport opens up. Go to Report > Record Selection formula and it should show {?pmSalesman_ID} = . Edit the selection formula to include the start and end date like this:
    *{?Pm-Salesman_ID} = and (ORDER_DATE >= {?Pm-@Start_date} or ORDER_DATE <= {?Pm-@End_date})*
    Let me know how this goes!
    -Abhilash

  • How to call webservice using java client

    Hi,
    I am new to webservice related stuff.Can any body help me.
    How can i call the webservice using simple java programing using jdeveloper tool is very useful for me.
    Thanks
    venuj

    user10394151 wrote:
    Hi,
    I am new to webservice related stuff.Can any body help me.
    How can i call the webservice using simple java programing using jdeveloper tool is very useful for me.
    Thanks
    venujTry this simple webservice client.
    You will need apache-axis.jar in your classpath. The following client is apache axis based. A similiar client can be built also using the JAX-WS only[without apache-axis.jar].
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import javax.xml.namespace.QName;
    public class WEBSERVICE_CLIENT{
    public static void main(String [] args) {
    try {
    String endpoint ="<YOUR WS ENDPOINT>";
            Service  service = new Service();
            Call     call    = (Call) service.createCall();
            // YOU CAN SET VARIOUS PROPERTIES IN THE "CALL" OBJECT...LIKE
            // USERNAME,PASSWORD,PROPERTIES OF HTTP HEADER. SEE "CALL" OBJECT'S API FOR MORE PROPERTIES.
            call.setTargetEndpointAddress( new java.net.URL(endpoint) );
            call.setOperationName(new QName("<YOUR WS SERVICE NAMESPACE>", "<WS SERVICE TO BE INVOKED>"));
            String msg = (String) call.invoke( new Object[] { "data" } );
            System.out.println("RETURNED MESSAGE : "+msg);
          } catch (Exception e) {
            System.err.println(e.toString());
    }

  • Create a webservice using java class

    Hi,
    I have a java class (which is used to open a URL). I need to create a webservice out of this so that I can publish this. Which is the best tool to convert java to a webservice and what are the steps.
    Any pointers on this would be of great help.
    Thanks,
    Shreevatsa

    If you are using Java 6 use JAX-WS to expose it as a webservice. See the JavaEE tutorial for more information.

  • How to pass Multi and Singlr value Parameters to DB2 query, which is using in SSRS report for ODBC connection

    Hi Guys,
    I am using DB2 database in SSRS. I have to pass Single Value and Multi Value Parameters. I tried with Select * From DB2Table Where
    Column=@PRM_Name Or Select * From DB2Table Where
    Column=:PRM_Name . It is not working and throwing error. Please help me out.
    Connection Details: ODBC
    Thanks Shiven:)

    Hi SKM,
    So you mean to say that Go to DataSource->Add Dataset-> Query Type-Text-> Under Query:
    click on fx (Expression)-> Write this expression
    For Single Value Parameter:
    ="SELECT customer_name, telephone_number, address1, address2, city from MyTable
    WHERE city = '" + Parameters!City.Value + "'"
    OR
    ="SELECT customer_name, telephone_number, address1, address2, city from MyTable
    WHERE city =  '" & Parameters!City.Value & "'"
    Keep it in mind if Parameter is String then
    It should be in Single quote ''.
     Like
    ="SELECT customer_name, telephone_number, address1, address2, city from MyTable WHERE city
    ='Hyderabad' "
    For Multivalu Parameter:
    ="SELECT EmployeeID, FirstName, LastName, LoginID FROM SHIVEN.AUDIT Where FirstName
    in ('" + REPLACE(JOIN(Parameters!City.Value,","),",","','") + "')"
    NOTE:
    If your Parameter is Single Value Parameter and You want to enter string values with Coma (,)
    separated (Like Hyderabad, Chennai, Delhi).
    In this case, you have to use below expression.
    ="SELECT customer_name, telephone_number, address1, address2, city from MyTable
    WHERE city IN ('" + REPLACE(Parameters!City.Value ,",","','") + "')"
    OR
    ="SELECT customer_name, telephone_number, address1, address2, city from MyTable
    WHERE city IN  ('" & REPLACE(Parameters!City.Value ,",","','") & "')"
    In above expression: Replace will replace all , with ‘,’ and city IN (‘Hyderabad’, ‘Chennai’,
    ‘Delhi’) will not throw any error.
     Note: You have to write expression in one line in Expression editor for dataset
    query
    Thanks It is working fine but it is tough job if query is big.
    Hi S kumar,
    The above approach we use when we have source like DB2, becasue DB2 has some syntactical differences to pass multivalue paramaeter. I tested and it works good, if i am mentioning the query in above format by using Fx button while creating dataset.
    but if we want fetch data from view which exist in DB2 and we need to call db2 view in SSRS and pass multivalue parameter in a way we did above then could you please mention the steps and way to achieve this.
    Thanks in advance!

  • Ho wto Dynamically Pass Parameters to a Query in Discoverer

    Hi All,
    I have a Query where I would to like to pass the Parameters Dynamically.In my query I have three selects and two UNION ALL's.In the three selects I have to pass Period & Year Parameters.In Each Select the Period Calculation is Different.Say in first & second select from the passed period parameter I calculate the previous Months.Whereas in the last select I do the the calculation with the Passed Period.How is it Possible with Discoverer..
    Thnx in Advance
    Rgds,
    Sai Srivatshav

    Hi,
    Well there is no straight forward way to do that.
    There is a work around to get that functionality by using outer tables or context.
    Take a look at the following posts:
    Re: Parameters in SubQuery
    Re: Parameters in Discoverer Administration
    Re: Passing multiple parameters into Custom Folder...

Maybe you are looking for