AUTO_INCREMENT (or equiv trigger?)

tfriedel

New Member
I have an application that relies heavily on AUTO_INCREMENT (I believe also called AUTONUMBER) data types. With these, Inserting NULL into a table causes this field to increment to the max available for that field. I need to move this to Progress SQL-92. Is such a datatype available. If no, must I write dozens of Java triggers to simulate ? If so, does anyone happen to have an example of such a trigger. The Progress Database Design Guide had a few java trigger examples, but not close enough for me to adapt.
thank you,
tom friedel
954-523-4182
 

tfriedel

New Member
This is what I came up with. Is there really no other way to have the database generate a key on INSERT than writing a Java trigger ?

My next issue is that I am getting frequent RPC errors itermittently with sqlexp and always inside JSP's. I probably should start a new thread.

tom


[JDBC Progress Driver]:Server not reachable or possible RPC error


DROP TABLE test ;
create table test ( test1 INTEGER ) ;

DROP TRIGGER mytrigger ;
CREATE TRIGGER mytrigger
AFTER INSERT ON test
IMPORT
import java.sql.*;
BEGIN

Integer max = new Integer(0) ;

SQLCursor sqlc = new SQLCursor( "SELECT MAX(test1) FROM test" ) ;
sqlc.open() ;
sqlc.fetch() ;
if ( sqlc.found () ) {
max = (Integer) sqlc.getValue(1, INTEGER);
}
sqlc.close() ;

int maxv = 0 ;
maxv = max.intValue() ;
maxv ++ ;

String stmt = "UPDATE test SET test1 = " + maxv + " WHERE test1 = 0 " ;
SQLIStatement update_stmt = new SQLIStatement( stmt ) ;
update_stmt.execute() ;

END;
 
Top