exam questions

Exam 1z0-151 All Questions

View all questions & answers for the 1z0-151 exam

Exam 1z0-151 topic 1 question 9 discussion

Actual exam question from Oracle's 1z0-151
Question #: 9
Topic #: 1
[All 1z0-151 Questions]

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?

  • A. If you place this Code in a trigger that fires when the record is inserted into the database, you will likely have more gaps in Order IDs than if you use the sequence as a default value for the item.
  • B. If you place this code in a trigger, you should ensure that Order_Id has its required property set to Yes.
  • C. If you place this code in a trigger, you should ensure that Order_Id has its Database Item property set to No.
  • D. If the named sequence does not exist, it is automatically created the first time the code is called.
  • E. You should place this code a in a database trigger to minimize the gaps in Order IDs.
  • F. You should place this code in Pre-insert trigger to minimize the gaps in Order IDs.
  • G. You should place this code in a Post_insert trigger to minimize the gaps in Order IDs.
Show Suggested Answer Hide Answer
Suggested Answer: F 🗳️
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;

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Currently there are no comments in this discussion, be the first to comment!
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...