Ver Mensaje Individual
  #2  
Antiguo 25-11-2004
Avatar de LordBits
LordBits LordBits is offline
Miembro
 
Registrado: nov 2004
Posts: 15
Reputación: 0
LordBits Va por buen camino
esta es la solucion que dan en www.ibphoenix.com..

Assume that you have already created a generator in your database as:

CREATE GENERATOR my_gen_id;

Examples:
Method 1: (SQL)
SELECT DISTINCT(GEN_ID(my_gen_id, 0))FROM table_name;
NOTE: Please notice that the increment value is (0) zero. This is to ensure
that you do not increment the generator when querying for its next value.

Method 2: (ISQL)
While attached to the database via an ISQL session type the following.
SQL> SHOW GENERATOR my_gen_id;

Method 3: (STORED PROCEDURE)
Code:
SET TERM !!;
CREATE PROCEDURE get_next_gen_value
RETURNS (next_value INTEGER)
AS
BEGIN
next_value = GEN_ID(my_gen_id, 0);
SUSPEND;
END !!
SET TERM ;!!

NOTE: Please notice that the increment value is (0) zero. This is to ensure
that you do not increment the generator when querying for its next value.
Once the procedure is successfully created you can issue a SELECT statement
against it.

SQL:
SELECT * FROM get_next_gen_value;
Responder Con Cita