The Orders database table uses Order_id as its primary key. You have written the following code to use in the Orders block of a form:
SELECT orders_seq.NEXTVAL
INTO :orders.order_id
FROM SYS.dual;
Which statement is true about this code?
Correct Answer: F
Explanation/Reference:
Explanation:
Assigning Sequence Numbers to Records
You will recall that you can assign default values for items from an Oracle sequence, to automatically provide unique keys for records on their creation. However, if the user does not complete a record, the assigned sequence number is "wasted."
An alternative method is to assign unique keys to records from a Pre-Insert trigger, just before their insertion in the base table, by which time the user has completed the record and issued the Save.
Assigning unique keys in the posting phase can:
* Reduce gaps in the assigned numbers
* Reduce data traffic on record creation, especially if records are discarded before saving Example
This Pre-Insert trigger on the ORDERS block assigns an Order ID from the sequence ORDERS_SEQ, which will be written to the ORDER_ID column when the row is subsequently inserted.
SELECT ORDERS_SEQ.nextval
INTO :ORDERS.order_id
FROM SYS.dual;