Wednesday, May 27, 2009

Progress Database - NextVal

Not sure how many people out there use the Progress database. I'm currently using it to connect a .NET 3.5 C# application to the Progress database using the Progress OpenEdge 10.1C driver.

Unfortunately, Progress does not support columns which have sequential numbers in it. In SQL Server or Oracle, you can specify a column's data type to be a bigint and an identity column. For instance:
CREATE TABLE dbo.Students (StudentID bigint identity(1,1),
StudentName varchar(20))

So in Progress, there isn't a such thing. Therefore, you need to set up a sequence in your database. Once you have set up your sequence, then in your code, you can do the following:

INSERT INTO pub.Students(StudentID, StudentName) VALUES (pub.sq_StudentID.NEXTVAL, 'Joe Schmoe')
The NEXTVAL function will retrieve the next value in the database for that sequence. I assume that it keeps track of it based on the sequence. To my knowledge, any sequence that you create is not tied to any database table. It simply resides as it's own sequence and keeps track of itself.

More information about the NEXTVAL function can be found on Progress' knowledge base website





No comments:

Post a Comment