I have two queries:
INSERT INTO CLASS
(TEACHER_ID, CLASS,)
VALUES (:i_teacher_id, :i_class)
INSERT INTO TEACHER_INFO
(TEACHER_ID, TEACHER_NAME) VALUES (:i_teacher_id, :i_teacher_name)
teacher_id is incremented by sequence like this: t0001, t0002, t0003 ...etc
Then I tried to do it:
INSERT INTO TEACHER_INFO
(TEACHER_ID, TEACHER_NAME) VALUES (teacher_seq.nextval, :i_teacher_name)
But sequence give me just "4" not t0004
If teacher_id must be in this format, and must be constructed as part of the insert statement, you could do this:
INSERT INTO TEACHER_INFO
(TEACHER_ID, TEACHER_NAME)
VALUES ('t'||LPAD(teacher_seq.nextval, 4, '0'), :i_teacher_name)
That is, add the initial "t", then append the next sequence number after padding it out to 4 digits with zeroes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.