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 -> How to get the current value of a sequence?

How to get the current value of a sequence?

From: <jojo7777_at_my-deja.com>
Date: Thu, 09 Dec 1999 10:24:04 GMT
Message-ID: <82o000$pt2$1@nnrp1.deja.com>


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

Original text of this message

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