Re: Transaction-based insert w/PHP?

From: Dror Matalon <dror(at)zapatec(dot)com>
To: SF Postgres <sfpug(at)postgresql(dot)org>
Subject: Re: Transaction-based insert w/PHP?
Date: 2003-02-13 01:01:47
Message-ID: 20030213010147.GV25317@rlx11.zapatec.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: sfpug

Josh,

As a rule I agree. The only exception is for tool writers. People like
us, who don't really know the structure of a table at run time, really
benefit from using OIDs. As long as you remember that they're not unique
across tables, you should be safe.

Dror

On Wed, Feb 12, 2003 at 04:52:45PM -0800, Josh Berkus wrote:
> David,
>
> > Does fetching that OID inside a transaction automatically guarantee
> > that the right thing happens?
>
> Maybe, maybe not. Regardless, you're making an easy task hard. You'd be
> better off staying away from OIDs entirely:
>
> > INSERT INTO foo (foo_desc)
> > VALUES ('too much unix!')
>
> > -- Fetch the $foo_id, or roll back if unable.
>
> $new_foo = currval('foo_foo_id_seq')
>
> > INSERT INTO bar (bar_desc, foo_id)
> > VALUES ('never too much unix!', $new_foo)
>
> I'd suggest reading the docs on sequences. There is no reason for you ever to
> use OIDs at all.
>
> --
> Josh Berkus
> Aglio Database Solutions
> San Francisco
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

--
Dror Matalon
Zapatec Inc
1700 MLK Way
Berkeley, CA 94709
http://www.zapatec.com

In response to

Responses

Browse sfpug by date

  From Date Subject
Next Message Josh Berkus 2003-02-13 01:03:55 Re: Transaction-based insert w/PHP?
Previous Message Dror Matalon 2003-02-13 00:59:41 Re: Transaction-based insert w/PHP?