Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: ORA-00439
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 =
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));
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