Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2007
    Posts
    7

    Unanswered: Update ResultSet In Java Stored Procedure

    I have the following Java Stored procedure which works fine, but what what I need to do is change one or more values in a field before I return the ResultSet. Can some show me an example of how to do that?

    Thank You

    Peter



    public class SQL1131
    {
    public static void abend (String input, ResultSet[] rsout) throws
    SQLException, Exception
    {


    int errorCode;

    try
    {

    Connection con = DriverManager.getConnection("jdbc:default:connecti on");

    String query = "SELECT * FROM STAFF WHERE JOB = ?";

    PreparedStatement pstmt = con.prepareStatement(query);
    pstmt.setString(1, input);
    rsout[0] = pstmt.executeQuery();


    }
    catch (SQLException sqle)
    {
    errorCode = sqle.getErrorCode();
    throw new SQLException( errorCode + " FAILED" );
    }

    }
    }

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    My first question is why you are doing such a simple procedure using java? Why not just make it a SQL stored procedure?

    I assume you just want to transform some of the columns returned. You can do that in the query itself.

    Andy

  3. #3
    Join Date
    Jan 2007
    Posts
    7

    Java SP

    Quote Originally Posted by ARWinner View Post
    My first question is why you are doing such a simple procedure using java? Why not just make it a SQL stored procedure?

    I assume you just want to transform some of the columns returned. You can do that in the query itself.

    Andy
    Because the logic to get the values is a lot more complicated, I have get the values from our ERP System.

  4. #4
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    I have written numerous SQL Stored Procedures that perform some very complicated queries. SQL is a pretty powerful language.

    Instead of dumbing down the query you want to perform, why don't you just show us in detail what you want to do?

    Andy

  5. #5
    Join Date
    Jan 2007
    Posts
    7

    Java SP

    The SQL DB2 Stored procedures can not call Business Functions in PeopleSoft, so I have to use Java and I have to return a ResultSet and some of the values are based on the return value from the Business Function.

  6. #6
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    I suggest that you change your query to do the data modification in the query itself. For example, you could use CASE expressions.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •