How to get the current value of a sequence?

From: <jojo7777_at_my-deja.com>
Date: Thu, 09 Dec 1999 11:58:44 GMT
Message-ID: <82o5hk$tb4$1_at_nnrp1.deja.com>



[Quoted] Hi to all,

[Quoted] [Quoted] 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.currvalue, 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.currvalue [Quoted] FROM dual");

--> Error message: "The sequence sequ is not declared in actual session"

[Quoted]     (or something similar)

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 - 12:58:44 CET

Original text of this message