You can not attach sequence to the field, though you may assign the value in trigger. Sequence has many options, but the simpliest (most common) command is
CREATE SEQUENCE <sequence name>
Then you may create "before insert row-level" trigger and assign sequence value to the field you need to be "attached":
CREATE SEQUENCE EMP_SEQ
CREATE TRIGGER EMP_BRI_TRG
BEFORE INSERT ON EMP
FOR EACH ROW
BEGIN
select emp_seq.nextval into :new.empno from dual;
END;
You should write it in sql*plus or any other sql command tool. :new is obviously not a text field in Forms and trigger is obviously not a Forms trigger, because you've asked about "field in the table", not about field in Forms block. If you need to make it in Forms, you may create pre-insert trigger and select sequence value into text item, but that's completely another story
If the code provided is EXACT, add semicolon after dual at least. It would be much better if you provide a little bit more information about error, at least its code, because it may be caused by dozens of your mistakes: wrong field/block/table names, no access to sequence etc.
You may also set Default Value property for block.textitem as :SEQUENCE.emp_seq.NEXTVAL instead. The drawback is that you may have a lot of gaps in your values.
I would like to know if I have 100 records how can I bring them back in a sequentially? Like record 1, record 2, record 3, record 4, record 5 and so on.
Note, that the records are "numbered" at the moment the result set already exists but before sorting it according to ORDER BY clause Thus conditions like rownum><some value> make no sence.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.