Re: easy way to insert same value into 2 columns
От | Sebastian Boeck |
---|---|
Тема | Re: easy way to insert same value into 2 columns |
Дата | |
Msg-id | 3F8E7B1D.9040407@freenet.de обсуждение исходный текст |
Ответ на | Re: easy way to insert same value into 2 columns (Jacob Vennervald <jvennervald@proventum.net>) |
Список | pgsql-general |
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
В списке pgsql-general по дате отправления: