In: Computer Science
QUESTION 34
seqAID is a valid Oracle sequence:
select seqAID.nextval
from dual;
the above query returns 1500, what the following query will return?
Select seqAID.nextval
From dual;
A.
1499
B.
1500
C.
1501
D.
1502
QUESTION 35
after running the query in previous Question, what the following query will return?
Select seqAID.nextval-1
From dual;
A.
1499
B.
1500
C.
1501
D.
1502
QUESTION 36
after running queries in previous two Questions (34 & 35), what the following query will return?
Select seqAID.currval
From dual;
A.
1499
B.
1500
C.
1501
D.
1502
SOL:
34) The following query
Select seqAID.nextval
From dual;
Returns 1501
1501 is the correct answer
so option C is correct
Explanation:
nextval increments the sequence and returns the next value
so it is given already that the above query returns 1500
so when we execute the query in question 34 . it increments the sequence value which is 1500 . so it becomes 1501 and returns it's value
so 1501 is the correct answer
35) The query
Select seqAID.nextval-1
From dual;
it returns the value 1500
so option B is the correct answer
Explanation:
we should run the query after running the query in 34 question
The First Nextval which is executed before the query 34 returns the initial value of the sequence which is 1500.
so every subsequent nextval statement in the query executed after this increments the 1500 by 1 and returns 1501 as the answer
In query 35 after 1501 is returned we are decrementing it by 1 . so The value returned by query is 1500
36) The Query
Select seqAID.currval
From dual;
Returns 1501
so 1501 is the correct answer
so Option C is correct
Explanation:
We should execute the query after executing queries in 34 and 35
we are using curval here
curval always returns the curval of the sequence . It is the value returned by the Last refference to Next val
so The Last Nextval statement in query 35 returned 1501
so The value returned by the query in 36 also 1501
so 1501 is the answer