Обсуждение:
I'm working on a sync conduit (for memos) from a Palm pilot to a postgresql database I'll simplify things a bit to convey my question. I have the main database table (notes) that has a note_id (primary key) and note_content fields I also have another table (called palm_memos) that matches up palm record ids to records in the notes database (via the note_id field) I think I have it working except for when there is a new record added to the Palm I need to add the contents of the new record in the Palm to the notes table (I can do this with an INSERT SQL statement). 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?
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