Re: How to get the current value of a sequence?

From: Roger Stapley <rstapley_at_uk.oracle.com>
Date: Fri, 10 Dec 1999 13:44:58 +0000
Message-ID: <385103DA.75FA729C_at_uk.oracle.com>


select last_number from all_sequences where sequence_name ='&seq_name';

HTH jojo7777_at_my-deja.com wrote:
>
> 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.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
> FROM dual");
>
> --> Error message: "The sequence sequ is not declared in actual session"
> (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 Fri Dec 10 1999 - 14:44:58 CET

Original text of this message