Previous Next Contents Index


ISequence interface (deprecated)

ISequence is deprecated and is provided for backward compatibility only.

The ISequence interface represents a sequence in an underlying database. Sequences are implemented in the database server to provide unique, incremental numbers assigned to records in a database. For example, the AppLogic can create a customer ID sequence to generate customer IDs, or create a purchase order sequence to generate purchase order numbers.

The ISequence interface provides methods to determine the current sequence value or to increment to the next sequence value. Sequences are useful for many types of applications, such as order entry applications.

The ISequence interface is part of the Data Access Engine (DAE) service.

To create an instance of the ISequence interface , use createSequence( ) in the ISequenceMgr interface (deprecated), as shown in the following example:

IDataConn dc;

dc = createDataConn(...);
ISequenceMgr sm;
sm = (ISequenceMgr) dc;
ISequence seq;
seq = sm.createSequence(...);
Package
com.kivasoft

Methods
Method
Description
drop( )
Deletes the sequence from the database.
getCurrent( )
Returns the current value in the sequence.
getNext( )
Increments the sequence and returns its incremented value.

Related Topics
createSequence( ) in the ISequenceMgr interface (deprecated)

drop( )
Deletes the sequence from the database.

Syntax
public int drop();
Usage
Use drop( )to remove a sequence from the database. Be careful when using this method. If the database implements the sequence as a field in a table, drop( ) will delete the entire table, not just the sequence field. If the database implements the sequence as an object, as does Oracle for example, drop( ) deletes only the sequence object.

Typically, once you start a sequence there is no reason to delete it. The sequence is normally used to create a permanent, unique numbering system for data in a database. However, you might use drop( ) if you are using the sequence mechanism to generate unique sequential numbers for a temporary programmatic purpose.

Return Value
GXE.SUCCESS if the method succeeds

Related Topics
createSequence( ) in the ISequenceMgr interface (deprecated)

getCurrent( )
Returns the current value in the sequence.

Syntax
public int getCurrent();
Usage
Use getCurrent( ) to obtain the current value of the sequence without actually incrementing the sequence value.

Alternatively, use getNext( ) to increment the sequence and obtain its incremented value.

Rule
For Oracle databases, the session must first call getNext( ) before it can call getCurrent( ).

Tip
UnlikegetNext( ) , calling getCurrent( ) does not change the value of the sequence.

Return Value
An int value representing the current value of the sequence, or -1 for failure.

Related Topics
createSequence( ) in the ISequenceMgr interface (deprecated)

getNext( )
Increments the sequence and returns its incremented value.

Syntax
public int getNext();
Usage
Use getNext( ) to increment and return the value of the sequence by the amount specified in the increment parameter in the createSequence( ) method in the ISequenceMgr interface (deprecated). The incrementation value is always a positive integer.

Alternatively, use getCurrent( ) to obtain the current value of the sequence without incrementing the sequence.

Return Value
An int value representing the next (incremente)d value of the sequence, or -1 for failure.

Rules
Tip
Successive calls to getNext( ) return successive integers.

Example
IDataConn conn;

conn = createDataConn(0, GX_DA_DAD_DRIVERS.GX_DA_DRIVER_ODBC,
"salesDB", "salesDB", "steve", "pass7878");

// Cast the connection to an ISequenceMgr interface
// and set up the sequence
ISequence seq;
seq = ((ISequenceMgr) conn).createSequence("mySeq", "orders.ID", 100, 1, null)

// To start the sequence, call getNext().
int seqVal;
seqVal = seq.getNext();

// Use the sequence number to perform the task for
// which you created it.
IQuery qry = createQuery();
qry.setSQL("INSERT into orders (ID) values ("+ seqVal +")," +
"(cust) values ("+ custname +")");
Related Topics
createSequence( ) in the ISequenceMgr interface (deprecated)

 

© Copyright 1999 Netscape Communications Corp.