Passing resultsets in a method

Hello all I am curious what the general thought/idea is about methods passing result sets to the caller - I am guessing bad idea correct ?

The reason that I am asking is because I am in a
situation where I need to be able to docomparisions
from one resultset to another, and putting all ofthe
code into one method makes it rather long.
So don't put all the code in one method! Split up the
code into tasks and code the tasks.Guess it will just take some engineering, as looking at it right away they all rely on each other, but I bet if I work at it a bit I can get everything split up.
Thanks again for all the info.
And no it's not possible to do it all in SQL, as some things are dependant on the previous comparison of 2 tables which require other things etc etc.

Similar Messages

  • Passing a resultset to a method

    Hi all,
    I want to pass a resultset object that is scrollable and updateable to a method. THe problem is that, the resultset object in the other method is not scrollable or updateable anymore.
    Eg.
    Statement stat = null;
    ResultSet rs = null;
    stat = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATEABLE);
    rs = executeQuery("SELECT * from table");
    rs.absolute(5); // when i use this, it works fine here, but it won't if i pass rs to another method
    method2(rs);
    // end of this method
    method2(ResultSet rs) {
    absolute(5); //this is where i am told that ResultSet is readonly and not updateable
    OFFCOURSE, ignore the syntax errors and stuff. I would greatly appreciate your help. I really need to figure this out otherwise i would have to rewirte a huge part of my code. Thank you very much

    warnerja is only partially right, it is true that database driver sometimes doesn't support updateable resultset, but my problem was solved by following this link
    http://www.oracle.com/forums/message.jsp?id=396810&pgm=otn&uid=1024413365365 (you have to register with oracle for that)
    for anybody who can't access the above page, the solution is
    instead of doing (SELECT * from abc), do (SELECT abc.* from abc)
    that should solve your problem if its the same as mine.
    HOWEVER, if i have multiple tables and if i do the following as above
    SELECT abc.*, zzz.channel, zzz.channel2, xyz.field1
    FROM abc, zzz, xyz
    the resultset remains readonly, i dont' know why
    ANY IDEAS???????

  • Passing Parameters via Post Method from Webdynpro Java to a web application

    Hello Experts,
    I want to pass few parameters from a web dynpro application to an external web application.
    In order to achieve this, I am referring to the below thread:
    HTTP Post
    As mentioned in the thread, I am trying to create an additional Suspend Plug parameter (besides 'Url' of type String) with name 'postParams' and of type Map.
    But when I build my DC, I am getting the same error which most of the people in the thread have mentioned:
    Controller XXXCompInterfaceView [Suspend]: Outbound plug (of type 'Suspend') 'Suspend' may have at most two parameters: 'Url' of type 'string' and 'postParams' of type 'Map'.
    I am using SAP NetWeaver Developer Studio Version: 7.01.00
    Kindly suggest if this is the NWDS version issue or is it something else that I am missing out.
    Also, if it is the NWDS version issue please let me know the NWDS version that I can use to avoid this error.
    Any other suggestion/alternative approach to pass the parameters via POST method from webdynpro java to an external web application apart from the one which is mentioned in the above thread is most welcome.
    Thanks & Regards,
    Anurag

    Hi,
    This is purely a java approach, even you can try this for your requirement.
    There are two types of http calls synchronous call or Asynchronous call. So you have to choose the way to pass parameters in post method based on the http call.
    if it is synchronous means, collect all the values from users/parameters using UI element eg: form and pass all the values via form to the next page is nothing but your web application url.
    If it is Asynchronous  means, write a http client in java and integrate the same with your custom code and you can find an option for sending parameters in post method.
    here you go and find the way to implement Asynchronous  scenario,
    http://www.theserverside.com/news/1365153/HttpClient-and-FileUpload
    http://download.oracle.com/javase/tutorial/networking/urls/readingWriting.html
    http://digiassn.blogspot.com/2008/10/java-simple-httpurlconnection-example.html
    Thanks & Regards
    Rajesh A

  • Passing parameter in a method

    hi i have a situation where i have to pass parameter to my method i don't what to pass the parameter define from the viewO because am not using parameter to query from the view,i just what to pass it to my procedure,my method is
                    public void submit_agr(String par_id,String dref_id,String tas_id,String agr_id){
                        ViewObject sub = this.findViewObject("AGR1");
                      i don't what to use this-> sub.setNamedWhereClauseParam("tas_id", tas_id); the tas_id is not in AGR1 VIEWO
                      // sub.
                        sub.executeQuery();
                        Row row = sub.first();
                        par_id = (String)row.getAttribute("par_id");
                        agr_id = (String)row.getAttribute("id");
                        callPerformSdmsLogon("SMS_FORM_TO_ADf.delete_agr(?)", new  Object[] {par_id,dref_id,tas_id,agr_id});
                    }

    i try this AM IN jDEVELOPER 11.1.2.1.0
                    public void submit_agr(String par_id,String dref_id,String tas_id,String agr_id){
                        ViewObject sub = this.findViewObject("AGR1");                 
                        Row row = sub.first();
                        sub.setNamedWhereClauseParam("tas_id", new Number(10));-how will i pass this to my procedure
                        sub.setNamedWhereClauseParam("dref_id", new Number(10));-how will i pass this to my procedure
                        par_id = (String)row.getAttribute("par_id");
                        agr_id = (String)row.getAttribute("id");
                        sub.executeQuery();
                        callPerformSdmsLogon("SMS_FORM_TO_ADf.delete_agr(?)", new  Object[] {par_id,dref_id,tas_id,agr_id});
                    }how will i pass the two prameter to my procedure
    Edited by: Tshifhiwa on 2012/07/01 3:14 PM

  • Passing object references to methods

    i got the Foo class a few minutes ago from the other forum, despite passing the object reference to the baz method, it prints "2" and not "3" at the end.
    but the Passer3 code seems to be different, "p" is passed to test() , and the changes to "pass" in the test method prints "silver 7".
    so i'm totally confused about the whole call by reference thing, can anyone explain?
    class Foo {
        public int bar = 0;
        public static void main(String[] args) {
                Foo foo = new Foo();
                foo.bar = 1;
                System.out.println(foo.bar);
                baz(foo);
                // if this was pass by reference the following line would print 3
                // but it doesn't, it prints 2
                System.out.println(foo.bar);
        private static void baz(Foo foo) {
            foo.bar = 2;
            foo = new Foo();
            foo.bar = 3;
    class Passer2 {
         String str;
         int i;
         Passer2(String str, int i) {
         this.str = str;
         this.i = i;
         void test(Passer2 pass) {
         pass.str = "silver";
         pass.i = 7;
    class Passer3 {
         public static void main(String[] args) {
         Passer2 p = new Passer2("gold", 5);
         System.out.println(p.str+" "+p.i);  //prints gold 5
         p.test(p);
         System.out.println(p.str+" "+p.i);   //prints silver 7
    }

    private static void baz(Foo foo) {
    foo.bar = 2;
    foo = new Foo();
    foo.bar = 3;This sets the bar variable in the object reference by
    foo to 2.
    It then creates a new Foo and references it by foo
    (foo is a copy of the passed reference and cannot be
    seen outside the method).
    It sets the bar variable of the newly created Foo to
    3 and then exits the method.
    The method's foo variable now no longer exists and
    now there is no longer any reference to the Foo
    created in the method.thanks, i think i followed what you said.
    so when i pass the object reference to the method, the parameter is a copy of that reference, and it can be pointed to a different object.
    is that correct?

  • Passing output to a method, I'm lost!

    I want to put all of my "output" including the returns on the three Temp functions in my method DisplayTemperatures, but I'm stuck and don't know how to do this. Please help
    import javax.swing.*;
    import java.text.DecimalFormat;
    public class Temp {
         public static void main(String[] args) {
              int Hourly_Temperatures[];
              String output;
              Hourly_Temperatures = new int[24];
              DecimalFormat twoDigits = new DecimalFormat ("00");     
              for (int i = 0;i < Hourly_Temperatures.length;i++) { //inputs temps               
                   Hourly_Temperatures[i] = Integer.parseInt(JOptionPane.showInputDialog("Enter temperature between -50 & 130\nHour: " + twoDigits.format(i) + ":00"));
                   while (Hourly_Temperatures[i] < -50|| Hourly_Temperatures[i] > 130) {
                        Hourly_Temperatures[i] = Integer.parseInt(JOptionPane.showInputDialog(null,"Invalid Entry!\nEnter temperature"));
              output = "Hour\tTemperature\n"; // build output string
              for (int counter = 0; counter < Hourly_Temperatures.length; counter++)
              output += twoDigits.format(counter) + ":00" + "\t" + Hourly_Temperatures[counter] + "\n";
              JTextArea outputArea = new JTextArea();
              outputArea.setText(output);
              JOptionPane.showMessageDialog(null,outputArea,"24 hour Temperature",JOptionPane.INFORMATION_MESSAGE);
              //System.exit(0);
         } //end main
         public int High_Temp(int Temperatures[]){
              int highTemp = Temperatures[0];
              for (int counter =0; counter < Temperatures.length; counter++)
              if (Temperatures[counter]>highTemp)
              highTemp = Temperatures[counter];
              return highTemp;
         }//end method High_Temp
         public int Low_Temp(int Temperatures[]){
                   int lowTemp = Temperatures[0];
                   for (int counter =0; counter < Temperatures.length; counter++)
                   if (Temperatures[counter]<lowTemp)
                   lowTemp = Temperatures[counter];
                   return lowTemp;
         }//end method Low_temp
         public int Average_Temp(int Temperatures[]){
              int total = 0;
              for (int counter =0; counter < Temperatures.length; counter++)
              total += Temperatures[counter];
              return total / Temperatures.length;
         }// end method Average_Temp
         public void Display_Temperatures(int Temperatues[], int Average_Temp){
        }// end method Display_Temperatures
    } //end class

    I am not sure I understand what problem you are having in passing output to the method. However, I'll guess:
    If you want to pass output to Display_Temperatures() then:
    1. change Display_Temperatures to accept a String
    2. move display code from main to Display_Temperatures.
    3. pass output to Display_Temperatures()
    Display_Temperatures(output)If you want to do all the calculations also in Display_Temperatures:
    1. change Display_Temperatures to accept only 1 arg - int[]
    2. move all the calculations & display code from main to Display_Temperatures
    3. pass Hourly_Temperatures to Display_Temperatures()
    Display_Temperatures(Hourly_Temperatures)If you make these changes then you will encounter some compilation errors. Post them here only after you've first tried to understand and fix them.
    If it is something else you want to do, then you will have to explain it better; at least I've not understood your problem.
    The naming standards that almost all jave professionals follow is:
    1. not to use underscore char ( _ ) in method names; so Display_Temperatures shd be DisplayTemperatures
    2. var names don't have _ char within the name and begin with a lower case; so Hourly_Temperatures shd be hourlyTemperatures
    It is generally a good practice to create an instance of the class in the main() method and write the process code in the instance methods instead of putting all that code in main() itself. Read the [url http://java.sun.com/docs/books/tutorial/]tutorials for this starting from the "Your First Cup of Java".

  • Passing objects to a method.

    Hi,
    I was reading this from a book and puzzled by this suggestion:
    for example:
    public Employee findEmployee(String employeeID);
    This method takes a String specifying a unique employee id and returns the Employee object with that id, null otherwise. Don't pass un-necessary objects to methods, and return the appropriate results.
    Why not passing objects to methods, I found it is convenient to pass objects to methods, why ?
    Thanks in advance !
    Tee

    Of course you can pass objects to methods. A String is also an object.
    The author doesn't say to not pass any objects to methods, only no unnecessary objects. He propably means that you don't need a method likepublic Employee findEmployee(String employeeID, String country)to retrieve the Employee if the employee ID by itself is unique or you don't use the country in the method, to give you an example.

  • Passing paramaters to a method

    I am passing objects to another method.
    I do some changes to them and expect the changed objects to be available in the calling method ( since they are supposedely passed by reference) when the execution is returned to it. However, I don't get the changed objects but rather the old ones, before the method execution.
    Can someone explain?
    Thanks,
    Boris.

    This is an extremely common question. A search through this forum would be very useful to you.
    Java does not pass-by-reference in the same way C/C++ do. When you pass an object to a method, you can change the contents of the object using its methods and see the changes after the method completes in the calling method. In this way Java is similar to C/C++.
    However, you cannot change an object to equal another object or a new object inside a method and expect the changes to be visible after the method completes in the calling method.
    Here is an example.
    This will show changes and the line "String" would be printed.
      StringBuffer sb = new StringBuffer();
      method(sb);
      System.out.println(sb);
      public void method(StringBuffer buf) {
        buf.append("String");
      }However, this would not show changes and the line "Old String would be printed:
      String string = "Old String";
      method(string);
      System.out.println(string);
      public void method(String string) {
        string = "New String";
        // string.concat("New String) would also fail to work

  • Passing parameters to a method

    I am passing objects to another method.
    I do some changes to them and expect the changed objects to be available in the calling method ( since they are supposedely passed by reference) when the execution is returned to it. However, I don't get the changed objects but rather the old ones, before the method execution.
    Can someone explain?
    Thanks,
    Boris.

    I do some changes to them and expect the changed
    objects to be available in the calling methodIf you modify an object passed to a method, then the changes made to that object will be visible as soon as they are made.
    If you change the parameter so that it references some other object, this will NOT be seen in the calling method.
    You can "fake" it by putting the object in question in an array and passing the array. Better though is to just not expect methods to be able to change references they are passed to point at some other object.

  • Passing hashtable to a method

    Can anyone show me the syntax to pass Hashtable to a method???
    c.buildHT(cal, ht); //where ht is the hashtable...
    buildHT(Calendar cal, Hashtable ht) {
    Is this OK? I tried....but I am getting errors...Can anyone clarify me about this?????

    I guess, instead of passing the entire HashTable, why dont you try passing only the keys of the hashtable, and accessing the values of the hashtable, thro' their respective keys

  • Passing information to a method

    Im going through the java tutorial about passing information to a method
    and i am presented with this code.
    class RGBColor {
        public int red, green, blue;
    class Pen {
        int redValue, greenValue, blueValue;
        void getRGBColor(RGBColor aColor) {// is aColor a reference for RGBColor ?
            aColor.red = redValue; //is aColor then used to access the variables of RGBColor ?
            aColor.green = greenValue;// Are these values being initialised here
            aColor.blue = blueValue;
    RGBColor penColor = new RGBColor();// we are creating an instance of RGBColor called penColor
    pen.getRGBColor(penColor);// this is the bit i dont understand where the heck did pen.getRGBColor come from, i cant see anywhere where pen has been declared ..... or instantiated
    System.out.println("red = " + penColor.red +
                       ", green = " + penColor.green +
                       ", blue = " + penColor.blue);The follwoing is what it says in the java tutorial about the code
    The modifications made to the RGBColor object within the getRGBColor method affect the object created in the calling sequence because the names penColor (in the calling sequence) and aColor (in the getRGBColor method) refer to the same object.
    any guidance would be great

    Directly above the code that you don't understand is
    o A definition for a class Pen.
    o something called "pen" is probably declared somewhere like this:
    Pen pen;
    or
    Pen pen = new Pen(....);
    or
    Pen pen = something.getPen();
    So pen is an instance of Pen, and you can invoke the methods defined in class Pen, thus
    pen.getRGBColor(....);

  • Concatenating VARCHAR2 to pass to a Java method

    Hi, I've imported in Oracle 10g a Java method which processes a String. I've mapped the String to a varchar2 as follow:
    create or replace function PARSE(input in varchar2) RETURN varchar2
    as language java
    name 'Base64.decodeToString(java.lang.String) return String';
    I then built a simple PL/SQL program to build the string to pass to the Java method as follows:
    create or replace procedure TEST_PARSE(input_tid in number) is
    begin
    declare
    result varchar2(32767);
    cursor object_cur is select TEXT from OBJECTSTORE where TID=input_tid order by rnumber;
    object_row object_cur%ROWTYPE;
    begin
    open object_cur;
    loop
    fetch object_cur into object_row;
    exit when object_cur%NOTFOUND;
    result := result || object_cur.TEXT;
    end loop;
    close object_cur;
    result := PARSE(result);
    end
    The PL/SQL program just concatenates the TEXT column from a bunch of records in the table OBJECTSTORE. The TEXT column is defined as a VARCHAR2(4000).
    Now if the SELECT in the TEST_PARSE program returns only 1 record, then everything works and the PARSE Java function returns the processed String.
    If the SELECT returns 2 or more records then I get the following warning and the Java method doesn't return anything:
    "Warning: PL/SQL procedure successfully completed with compilation errors"
    Since I know that the Java method works fine (it has been tested within java programs successfully ) I think the problem is something to do with data types or maybe with the size of the concatenated string.
    Any help really appreciated. Thank you!

    Thanks guys, it still doesn't work, but at least now I can see some error messages:
    Error code -24345: ORA-24345: A Truncation or null fetch error occurred
    1) The error occurs when I call the Java method. As before this happens only when the select returns more than 1 record and I concatenate two or more TEXT (each one is a VARCHAR2(4000)). However the concatenation works fine so I guess the problem is that the resulting string is too big for the Java method to process.
    Or maybe the string returned by the Java method is too big for the PL/SQL varchar2?
    2) Also why do I get a compilation error if I try to add the size of the varchar2 in the mapping below?
    create or replace function PARSE(input in varchar2) RETURN varchar2
    as language java
    name 'Base64.decodeToString(java.lang.String) return String';

  • Pass parameter to success method of ExecuteQueryAsync

    I have seen how to pass a parameter to a callback method of the ExecuteQueryAsync SP.ClientContext object.  The problem occurs when multiple calls are performed.  The last value is always passed to the callback method.  Below is a sample
    of a while loop that performs multiple updates.  cT contains the value i wish to pass.  TitleVal in the success method always contains the last value. 
    Thanks in advance.
    While...{ cT = currentItem.get_item('Title'); ListItem.set_item("Approval_x0020_Status", currentItem.get_item('Approval_x0020_Status'));
    ListItem.set_item("Year", currentItem.get_item('Year'));
    ListItem.set_item("Delete_x0020_this_x0020_Risk_x00", currentItem.get_item('Delete_x0020_this_x0020_Risk_x00'));
    ListItem.update();
    var SPContextUPD = new SP.ClientContext.get_current();
    SPContextUPD.executeQueryAsync(
    Function.createDelegate(this, function() {
    CreateListItem_Success("'" + cT + "'");
    Function.createDelegate(this, function() {
    CreateListItem_Fail();
    function CreateListItem_Success(TitleVal){
    SP.UI.Notify.addNotification(TitleVal + ' updated successfully');

    also define cT variable inside loop body by adding "var" so it will have narrower scope:
    var cT = currentItem.get_item('Title');
    If it is global it may store the last updated ct value which explains why you always see the same value.
    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - http://camlex.codeplex.com

  • Passing Tables from one method to another method.

    Hi All,
    I'm creating a Web-Dynpro program in which I wouild like to passing an internal table from one method to another method within the same View. 
    Is this possible?  And if so, how can I set it up.
    Thank you.
    Paul

    Hi Paul ,
    I hope u wud be clear with passing table from one method to another now .U may also wish to see this WIKI
    Link: [Passing table parameters|https://wiki.sdn.sap.com/wiki/display/WDABAP/Passingtableparameterfromoneviewtoanotherview+locally]
    I hope it wud help u .
    regards,
    amit

  • How to pass parameter to action methods

    Hi,
    I have a button.  Enter action method is associated with this.  In the Enter action method, I have added a parameter named param1.  When the button is clicked, this method is called automatically.  But how do I pass parameters to this method, which I have declared ?
    Regards,
    Suresh.

    Hi Suresh Babu,
    The associated method (Event Handler) is triggered by default and cannot pass the values. Instead, use the context node or attributes to set/get the values in the event handler method.
    Regards,
    Sravan Varagani

Maybe you are looking for