Re: mysql_insert_id

From: Erkin Tek <erkintek(at)fotograf(dot)web(dot)tr>
To: pgsql-tr-genel(at)postgresql(dot)org
Subject: Re: mysql_insert_id
Date: 2006-12-04 11:18:47
Message-ID: 200612041318.47241.erkintek@fotograf.web.tr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-tr-genel

Ben onu "select nextval('bir_seq')" ile önce id alıp, sonra buna göre "insert"
yaparak çözmüştüm.
Ama sanki "bir_seq" sequence'i işlem hatalı gitsede bir artacak gibi geldi.

Bu returning'i bilmiyordum, teşekkür ederim.
Pts 04 Ara 2006 09:18 tarihinde, Devrim GUNDUZ şunları yazmıştı:
> Merhaba,
>
> On Fri, 2006-12-01 at 16:30 +0200, Erkin Tek wrote:
> > bir kaç fln filan buldum ama sanırım eklediğim şeyi bulmanın yolu pek
> > yok, bir transaction yazmadıkca.
>
> PostgreSQL 8.2'teki INSERT...RETURNING işinize yarayabilir sanırım:
>
> test=# CREATE TABLE t1 (c1 serial unique, c2 varchar(20));
> NOTICE: CREATE TABLE will create implicit sequence "t1_c1_seq" for
> serial column "t1.c1"
> NOTICE: CREATE TABLE / UNIQUE will create implicit index "t1_c1_key"
> for table "t1"
> CREATE TABLE
> test=# INSERT INTO t1 VALUES (DEFAULT,'Devrim') RETURNING c1;
> c1
> ----
> 1
> (1 row)
>
> INSERT 0 1
> test=# INSERT INTO t1 VALUES (DEFAULT,'Gündüz') RETURNING c1;
> c1
> ----
> 2
> (1 row)
>
> İyi çalışmalar,

In response to

Responses

Browse pgsql-tr-genel by date

  From Date Subject
Next Message Devrim GUNDUZ 2006-12-04 12:29:04 Re: mysql_insert_id
Previous Message Devrim GUNDUZ 2006-12-04 07:18:40 Re: mysql_insert_id