Skip to Content
Former Member
Nov 12, 2008 at 06:42 AM

Generating serial numbers for primary key field


I am updating a table through a screen.

The primary key field is a char type field. The value (serial numbers) for the primary key field has to be generated automatically, once if I create a new record.

I used the following logic:

  • mcode is the key field.

select max( mcode ) into value1 from zcodes.

mcode = value1 + 1. " the newly generate field would be incrementated by 1 to have this value.

problem: But since the key field is char type, maximum value is not fetched properly after some values.

How can I do this? suggest me a logic.