Re: New ID - Mailing list pgsql-novice

From Josh Berkus
Subject Re: New ID
Date
Msg-id web-693002@davinci.ethosmedia.com
Whole thread Raw
In response to  ("Brian Johnson" <bjohnson@jecinc.on.ca>)
List pgsql-novice
Brian,

> What I don't know how to do is to get that newly created note_id so
>  that I
> can insert it into the palm_memos table
>
> Any ideas / advice?

Easy (please taylor to your programming language):

BEGIN TRANSACTION;

INSERT INTO notes (fields)
VALUES (new stuff);

$variable = SELECT CURRVAL('name-of-sequence-for-notes_id')

INSERT INTO palm_memos (notes_id, other fields)
VALEUS ($variable, other fields);

END TRANSACTION;

Make sense?

-Josh


______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus
  Complete information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco

pgsql-novice by date:

Previous
From: "Brian Johnson"
Date:
Subject:
Next
From: "Patrick Hatcher"
Date:
Subject: Re: Function Hangs