Re: get last oid

Поиск
Список
Период
Сортировка
От Shachar Shemesh
Тема Re: get last oid
Дата
Msg-id 3FE2E32F.5080303@shemesh.biz
обсуждение исходный текст
Ответ на Re: get last oid  ("Ropel" <ropel@ropel.it>)
Список pgsql-odbc
Ropel wrote:

>... In a well designed relational Db, every table has a (unique) primary
>key: if so, you don't even need to
>know the oid, because the record just inserted is directly reachable using
>the PK.
>If your PK uses sequences, you have to get the next seq value "select
>nextval() from seq_xxxxx..." and use the
>value obtained for inserting your new row instead of using it as a default
>value; this way you are protected from
>concurrent writing to the DB.
>
>If you REALLY need the oid from the ODBC connection, I can't help... sorry !
>
>Bye
>
>Roberto
>
>
>
Actually, if you created the sequence implicitly by using the "serial"
type, you don't even have to do that. You can simply do this:
creating the table:
create table foo (index serial not null, a type,  b type.....);
inserting into the table:
insert into foo (a,b,....)....

I.e. - leave the serial field out of the insert, and it will
automatically be set to the next sequence from the table.

--
Shachar Shemesh
Open Source integration & consulting
Home page & resume - http://www.shemesh.biz/



В списке pgsql-odbc по дате отправления:

Предыдущее
От: "Ropel"
Дата:
Сообщение: Re: get last oid
Следующее
От: "sqllist"
Дата:
Сообщение: Re: get last oid