develooper Front page | perl.beginners | Postings from March 2002

Perl & SQL help! Need to insert records into two tables

Thread Previous | Thread Next
From:
Brian Johnson
Date:
March 12, 2002 06:04
Subject:
Perl & SQL help! Need to insert records into two tables
Message ID:
004001c1c9cf$22f3c9a0$3200a8c0@jecinc.on.ca
I'm trying to add a new record (new values) into one table and I have a
second table that refers to the record number of the first table.

I can get the SQL statement to grab the current value of the incrementing
record number to work, but I need to translate this to operate in perl (I'm
not used to dealing with multiple SQL statements in perl - usually just a
select or an insert)

INSERT INTO notes (fields)
VALUES (new stuff);
$variable = SELECT CURRVAL('name-of-sequence-for-notes_id')
INSERT INTO palm_memos (notes_id, other fields)
VALUES ($variable, other fields);


Could someone post how to do this please?

Is there a better way to accomplish the objective?  I'm a little nervous
that in a multi-user system the database may slip in another INSERT
statement from another user prior to this routine getting the current value
of the incrementing record number and thereby throwing off the returned
value


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About