I have a table where I would like the primary key to be generated during
the insert.
Here is a simplified example:
CREATE TABLE employee_type
{
tname varchar(10) PRIMARY KEY,
id_prefix char(1) ;
...
}
tname | id_prefix
--+--
worker | W
manager | M
On Thursday 06 November 2008, EXT-Rothermel, Peter M
[EMAIL PROTECTED] wrote:
I have thought about using the serial data type for the employee.id but
I also want to automate the prepending of the { W, M, E } prefix.
You'll need write a before-insert trigger to assign the ID.
--
Alan
--
EXT-Rothermel, Peter M wrote:
I have a table where I would like the primary key to be generated during
the insert.
Here is a simplified example:
CREATE TABLE employee_type
{
tname varchar(10) PRIMARY KEY,
id_prefix char(1) ;
...
}
tname | id_prefix
--+--