Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: ORA-00439

Re: ORA-00439

From: <stevedhoward_at_gmail.com>
Date: 25 Apr 2006 08:10:17 -0700
Message-ID: <1145977817.192790.201940@g10g2000cwb.googlegroups.com>


Ed,

I assume the developer is using a stored procedure or function, but the example below works with the thin driver (which is usually more restrictive, so it should work everywhere)...

SQL> create table t0425(c number, d varchar2(20));

Table created.

SQL> create sequence t0425_s;

Sequence created.

SQL> create or replace trigger t0425_bir   2 before insert on t0425
  3 for each row
  4 declare
  5 l_number number;
  6 begin
  7 select t0425_s.nextval into l_number from dual;   8 :new.c := l_number;
  9 end;
 10 /

Trigger created.

SQL> host type testIns.java
import java.sql.*;

public class testIns {
  public static void main(String args[]) {     try {

      Class.forName("oracle.jdbc.driver.OracleDriver");
      Connection conn =

DriverManager.getConnection("jdbc:oracle:thin:@localhost :1521:test10g","rep","rep");

      CallableStatement cstm = conn.prepareCall("begin insert into t0425(d) valu
es('becky') returning c into ?; end;");

      int l_num = 0;
      cstm.registerOutParameter(1,java.sql.Types.INTEGER);
      cstm.execute();
      System.out.println(cstm.getInt(1));

}

    catch (Exception e) {
      System.out.println(e);
}

  }
}
SQL> host javac testIns.java

SQL> host java testIns
1

SQL> host java testIns
2

SQL> host java testIns
3

SQL> select * from t0425;

         C D

---------- --------------------
         1 becky
         2 becky
         3 becky

SQL> If it is a stored procedure or function, then the example above would also work by changing the text of the CallableStatement piece.

Regards,

Steve Received on Tue Apr 25 2006 - 10:10:17 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US