Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004
    Posts
    1

    Unanswered: call Oracle Function from java

    first of all ... i don't know english very vell and sorry about it ..... then ...
    i have a function in oracle like that :

    Code:
    create or replace function sf_SearchStudent(
           nID in  number
           ) 
    return MyPackage.CursorType is
    Result MyPackage.CursorType;
    begin
      open Result for select * from STUDENT where ID=nID;
      return Result;
    end sf_SearchStudent;
    and it's working fine but from java i wrote code like that :


    Code:
    CallableStatement callst = conn.prepareCall("{?=call sf_SearchStudent(?,?,?,?)}");                                            
          callst.registerOutParameter(1, OracleTypes.CURSOR);
          callst.setInt(1,id);
          callst.setString(2,name);
          callst.setString(3,surname);
          callst.setInt(4,age);
          callst.executeUpdate();   ------->>>>> ERROR Occur
    
          ResultSet res = ((OracleCallableStatement)callst).getCursor(4);
          while (res.next())
          {
           System.out.println(res.getInt("ID"));
           System.out.println(res.getString("NAME"));
           System.out.println(res.getString("SURNAME"));
           System.out.println(res.getInt("AGE"));
         }
    but here is an error but i don't know why please help me ..... F!

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by paata

    Code:
    CallableStatement callst = conn.prepareCall("{?=call sf_SearchStudent(?,?,?,?)}");                                            
          callst.registerOutParameter(1, OracleTypes.CURSOR);
          callst.setInt(2,id);
          callst.setString(3,name);
    etc.
    ...............................................

Posting Permissions

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