Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: question about sequences.

Re: question about sequences.

From: Malcolm Stonebridge <malc_at_stoneyb.freeserve.co.uk>
Date: Sun, 16 Feb 2003 22:35:01 -0000
Message-ID: <b2p3mn$res$1@news7.svr.pol.co.uk>


Surely if we follow Occam's razor, the simplest explanation is usually the correct one (or you should not pad out explanations with complexity if you don't need to), then the misunderstood question about mysequence.currval and mysequence.nextval would be the most reasonable/likely explanation. After all, what kind of a total plank would insert extra rows into Dual !???

Malcolm

"DA Morgan" <damorgan_at_exesolutions.com> wrote in message news:3E50096D.F98CEF4B_at_exesolutions.com...
> Jim Kennedy wrote:
>
> > Daniel,
> > Sure we don't know what the interviewer was thinking, but this the type
of
> > question that one might use to dig for experience and problem solving.
It
> > is likely the sequence question alone is fairly simple and
straightforward
> > (one would hope), but by combining it with this "odd" behavior (Hmm, got
2
> > rows back from dual.) The interviewer is asking both about sequences,
what
> > dual is, and why might it be acting unusual.(have 2 rows) It is the
type of
> > thing that would happen in real life (some bozo did an insert into dual
and
> > now it has 2 rows, and is creating all sorts of havoc.)
> > Jim
> > "DA Morgan" <damorgan_at_exesolutions.com> wrote in message
> > news:3E4FD982.EDE9B0B0_at_exesolutions.com...
> > > Jim Kennedy wrote:
> > >
> > > > I think the question was aimed at finding out that someone had added
a
> > row
> > > > to dual and that will cause problems with applications that use dual
> > > > expecting 1 row.
> > > > Jim
> > > >
> > > > --
> > > > Replace part of the email address:
kennedy-down_with_spammers_at_attbi.com
> > > > with family. Remove the negative part, keep the minus sign. You
can
> > figure
> > > > it out.
> > > > <Kenneth Koenraadt> wrote in message
> > > > news:3e4f8b9d.629164_at_news.inet.tele.dk...
> > > > > On Sat, 15 Feb 2003 18:17:04 GMT, "Ryan" <rgaffuri_at_cox.net> wrote:
> > > > >
> > > > > >I got a trick question in an interview and I dont know if what I
said
> > was
> > > > > >write. It was a written exam so I couldnt ask.
> > > > > >
> > > > > >Someone does
> > > > > >
> > > > > >select sequence.nextval
> > > > > > from dual;
> > > > > >
> > > > > >you get two sequence numbers back. All I could think of was that
> > someone
> > > > > >inserted a second row into dual.
> > > > > >
> > > > > >Could any other reason lead to two sequence numbers being
returned?
> > > > > >
> > > > > >
> > > > >
> > > > > Hi Ryan,
> > > > >
> > > > > Maybe the question was just awkwardly asked. I guess they wanted
to
> > > > > test if you knew about both sequence.NEXTVAL and sequence.CURRVAL
:
> > > > >
> > > > > Nextval is returned from the statement. No doubt. And if you
> > > > > afterwards do :
> > > > >
> > > > > select sequence.currval from dual;
> > > > >
> > > > > You get the same value again. In that sense, you can say that you
get
> > > > > 2 values at your service, *because* :
> > > > >
> > > > > If you start a user session and have a sequence myseq and issue :
> > > > >
> > > > > select myseq.currval from dual;
> > > > >
> > > > > You get ORA-08002: Sequence MYSEQ.CURRVAL not yet defined.....
> > > > >
> > > > > You have to invoke NEXTVAL by *first* calling
> > > > >
> > > > > select myseq.nextval from dual;
> > > > >
> > > > > and *then* you can do ;
> > > > >
> > > > > select myseq.currval from dual;
> > > > >
> > > > > So "select sequence.nextval from dual" does, make another value
> > > > > avilable : sequence.currval.
> > > > >
> > > > > Interviewers trying to make tricky questions, are often tricking
> > > > > themselves instead....
> > > > >
> > > > > - Kenneth Koenraadt
> > > > >
> > > > >
> > > > >
> > >
> > > As opposed to SELECT COUNT(*) FROM dual;?
> > >
> > > The question is reasonable as a way of understanding someone's
> > understanding of
> > > dual and how sequences work. Trying to psychoanalyze those that put
> > together the
> > > questions may not lead to a lot of clarity as we'll likely never know
why
> > any
> > > question ends up on one of these things.
> > >
> > > What I find more amazing is the questions and answers (especially on
the
> > OCP)
> > > that are clearly incorrect.
> > >
> > > Daniel Morgan
> > >
>
> Hope you didn't misunderstand ... I think it is a great question and plan
to add
> it to my repetoire for just the reasons you cite.
>
> Daniel Morgan
>
Received on Sun Feb 16 2003 - 16:35:01 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US