kamasabi
April 17th, 2008, 02:31 AM
gents,
Anyone have some experience with SQL and triggers? Attempt:
I have a table, for instance tutor, that has a TutorID that I want to auto increment, however, it is a char string, in this case, t001, t002, etc. If it were simply a number, it wouldn't be an issue. So, what I want to do....
I want to make a trigger or stored function that breaks that char into 2 segments: the character and the numbers, then increment the numeric part, and then piece the two back together.
Or if there is an easier method of doing this, that'd be cool too :)
here is the actual table creation entry:
CREATE TABLE Tutor (
TutorID char(4) NOT NULL,
TutorMajor VARCHAR(40) NOT NULL,
TutorName VARCHAR(40) NOT NULL,
TutorAddress VARCHAR(50) NOT NULL,
TutorPhone number(10) NOT NULL,
TutorEmail VARCHAR(50) NULL,
PRIMARY KEY(TutorID)
);
Any ideas? Working in Oracle 10g Express.
-Kama
Anyone have some experience with SQL and triggers? Attempt:
I have a table, for instance tutor, that has a TutorID that I want to auto increment, however, it is a char string, in this case, t001, t002, etc. If it were simply a number, it wouldn't be an issue. So, what I want to do....
I want to make a trigger or stored function that breaks that char into 2 segments: the character and the numbers, then increment the numeric part, and then piece the two back together.
Or if there is an easier method of doing this, that'd be cool too :)
here is the actual table creation entry:
CREATE TABLE Tutor (
TutorID char(4) NOT NULL,
TutorMajor VARCHAR(40) NOT NULL,
TutorName VARCHAR(40) NOT NULL,
TutorAddress VARCHAR(50) NOT NULL,
TutorPhone number(10) NOT NULL,
TutorEmail VARCHAR(50) NULL,
PRIMARY KEY(TutorID)
);
Any ideas? Working in Oracle 10g Express.
-Kama