1Z0-151 · Question #79
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…
The correct answer is F. You should place this code in Pre-insert trigger to minimize the gaps in Order IDs. 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…
Question
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?
Options
- AIf you place this Code in a trigger that fires when the record is inserted into the database, you will likely
- BIf you place this code in a trigger, you should ensure that Order_Id has its required property set to Yes.
- CIf you place this code in a trigger, you should ensure that Order_Id has its Database Item property set to No.
- DIf the named sequence does not exist, it is automatically created the first time the code is called.
- EYou should place this code a in a database trigger to minimize the gaps in Order IDs.
- FYou should place this code in Pre-insert trigger to minimize the gaps in Order IDs.
- GYou should place this code in a Post_insert trigger to minimize the gaps in Order IDs.
How the community answered
(34 responses)- A3% (1)
- C6% (2)
- D12% (4)
- F76% (26)
- G3% (1)
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 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 SELECT ORDERS_SEQ.nextval INTO :ORDERS.order_id
Topics
Community Discussion
No community discussion yet for this question.