"H�bschen, Peter" wrote:
>
> I've tried what is described in this howto below (SAPDB
> 7.4.03.25). But for
> me it doesn't work or do I have a misunderstanding.
> I have some tables where I have a line like this:
> i.e. definition of table Test1:
> <snip>
> "<column name>" Integer NOT NULL DEFAULT
> SERIAL (1)
> </snip>
> The number generator works. But if I do a "Select
> Test1.Currval from test1"
> I get error -2029 ("Currval is not yet defined."). So I made a "Select
> Test1.Nextval from test", then I get error -4020 ("Unknown
> sequence name").
> So I don't get the current value back.
>
> Maybe it has something to do with my definition?
>
> Thanks in advance
> Peter
>
CURRVAL will only do if NEXTVAL was done in the same session.
In your case it would be an implicit NEXTVAL by doing some insert
into that table (in the same session!)
The mechanism with <tablename>.CURRVAL will only work after
an insert into the corresponding table in the same session
and will then return the last inserted serial-value of that session.
it will not return the last inserted value inserted three weeks ago
with another session. for this MAX(column) would be needed.
Elke
SAP Labs Berlin
>
> > -----Urspr�ngliche Nachricht-----
> > Von: Zabach, Elke [SMTP:[EMAIL PROTECTED]
> > Gesendet am: Freitag, 5. September 2003 08:46
> > An: 'Stephan Stapel'; [EMAIL PROTECTED]
> > Betreff: RE: id of the lastly inserted record
> >
> >
> >
> > Stephan Stapel wrote:
> > >
> > > Dear list,
> > >
> > > though it was already asked before several times, there
> was never a
> > > satisfying answer to this.
> >
> > The answer given in here
> > http://www.sapdb.org/7.4/how_tos/numbergen/datentypserial_eng.htm
> > and in so many mails of this list is not satisfying? What
> do you expect?
> >
> > Elke
> > SAP Labs Berlin
> >
> > > Is it possible and if so, how, to retrieve the id of an
> > > record that was
> > > inserted. This should however for sure only be possible in
> > > case of using
> > > "technical keys", i.e. with an (unsigned) integer as the pk
> > > and also only be
> > > necessary in case of using SERIAL(n).
> > > If there is no possibility or at least work-around, using
> > > SERIAL(n) for a pk
> > > should make no sense it all, does it?
> > >
> > > Thanks for your help in advance!
> > >
> > > Kind regards,
> > >
> > > Stephan
> > >
> > > --
> > > COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test
> > > --------------------------------------------------
> > > 1. GMX TopMail - Platz 1 und Testsieger!
> > > 2. GMX ProMail - Platz 2 und Preis-Qualit�tssieger!
> > > 3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7.
> > > daybyday - 8. e-Post
> > >
> > > _______________________________________________
> > > sapdb.general mailing list
> > > [EMAIL PROTECTED]
> > > http://listserv.sap.com/mailman/listinfo/sapdb.general
> > >
> > _______________________________________________
> > sapdb.general mailing list
> > [EMAIL PROTECTED]
> > http://listserv.sap.com/mailman/listinfo/sapdb.general
> >
> >
> _______________________________________________
> sapdb.general mailing list
> [EMAIL PROTECTED]
> http://listserv.sap.com/mailman/listinfo/sapdb.general
>
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general