Problem: How do I display the current value for a generator? Solution: Scenario: 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 incriment value is (0) zero. This is to ensure that you do not incriment 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: ---------------snip----------------------- SET TERM !!; CREATE PROCEDURE get_next_gen_value RETURNS (next_value INTEGER) AS BEGIN next_value = GEN_ID(my_gen_id, 0); END !! SET TERM ;!! ---------------snip----------------------- NOTE: Please notice that the inceiment value is (0) zero. This is to ensure that you do not incrieent 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;
Last Modified: 29-SEP-00