Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Adding a sequence as a default value to a tabular column field

Richard LeggeMay 6 2014 — edited May 8 2014

Hi All,

APEX 4.2.4. Oracle XE 11.2

I'm trying to add a default value from a sequence to a tabular column field, so that it populates when I hit the 'Add Row' button..

The reason for this by the way, rather than just using a database Sequence and trigger on the column (which exists and works fine), is that I'm also trying to add detail records to the row when I create it, and I cannot unless I have the parent ID to pass to the Child records.

Looking at the docs, (for example pl/sql enhancements in oracle 11g), I thought Id have be able to use a PL/SQL expression such as to_char(petty_cash_seq.NEXTVAL) or to_number(petty_cash_seq.NEXTVAL) or any such expression that retrieves the sequence.nextval, as this became available in PL/SQL on Database

so, Ive tried

to_char(petty_cash_seq.NEXTVAL) in tabular form attributes - default column / PL/SQL expression, and it tells me  ORA-02287: sequence number not allowed here...

Ive also tried wrapping it up in a PL/SQL package, as below: 

DECLARE v_seq_value NUMBER; BEGIN select petty_cash_seq.NEXTVAL into v_seq_value from dual;return v_seq_value; END;

and I get ORA-00923: FROM keyword not found where expected...

Can anyone help as to why either of these don't appear to work as an expression / package in the default type??

or..... a simple alternative to get the ID of the next record when I hit 'Add Row' so that I can create child records at the same time...

And I have been mulling over the merits of master / detail integrity, and trying to think of a neat way to create the master, add the details without having to submit the master first, then go back and enter details.... And to put it in context, its an expense application where users create an expense entry, and upload copies of their expenses at the same time...

Many Thanks

Richard

This post has been answered by Joseph Upshaw on May 8 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 5 2014
Added on May 6 2014
7 comments
8,039 views