Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> How to get the current value of a sequence?
Hi to all,
I have a problem with sequences in Oracle 8i:
how can I get the current value (currvalue) of a database sequence with a Java application?
(sys.sequ is declared as a sequence in the database)
The following Java code works properly:
java.sql.Connection conn;
java.sql.Statement stmt = conn.createStatement();
java.sql.ResultSet rset = stmt.executeUpdate("INSERT INTO sys.table1 VALUES (sys.sequ.currval, 2)");
This code results in a error message created by oracle:
java.sql.Connection conn;
java.sql.Statement stmt = conn.createStatement();
java.sql.ResultSet rset = stmt.executeQuery("SELECT sys.seq.currval FROM dual");
--> Error message: "The sequence sequ is not declared in actual session"
(or something similar)
The same error message is returned when I execute the query directly via SQL+ Monitor.
My problem:
I need the current value of the sequence to read it from the ResultSet in a variable.
thanks in advance
Jojo
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Thu Dec 09 1999 - 04:24:04 CST