Jacob Vennervald wrote:
>>Thanks a lot, but is it save to use?
>>
>>Do i always get the same value, even if an other insert is changing
>>the sequence >public.zeit_id_seq< just at the same time?
>
> Yes. currval() gives you the last id of the sequence in your session.
> So if others log in and insert more rows it wont affect your session.
>
> Can I ask why you would wanna do that anyway?
>
> Jacob
Sure!
I have several tables with an inheritance hierachy.
The first one (zeit) has a Serialfield called id.
All other tables inherit from this one, so that i have
an absolutely unique id over all tables. But if i want
to reference the id of a table in the middle of the
hierarchy-chain, it won't work, because it's not the
tables own index. Therefore i need an duplicated value.
On this column i can create another index that can be
used as an foreign key by other tables.
Are there any other ways to accomplish this?
Regards
Sebastian