Re: To find a just-inserted record

2002-01-08 Thread S P Arif Sahari Wibowo
On Fri, 21 Dec 2001, Sterin, Ilya wrote: >Depends on the database you are using? Thank you for all who answer my question, but apparently it really depend on the database - no generic answer. Except probably to make sure the table have a primary key and generate the key in the Perl script before

RE: To find a just-inserted record

2001-12-28 Thread Florian Helmberger
Hi. > PostgreSQL: > $dbh->do(CREATE SEQUENCE table_uid_seq) > $dbh->do(CREATE TABLE table ( uid INT4 DEFAULT nextval('table_uid_seq') > )) > $dbh->do(INSERT INTO table (table_uid_seq.NEXTVAL, field...) VALUES (...)) > $dbh->...(SELECT last_value as unique_id FROM table_uid_seq) This way to

Re: To find a just-inserted record

2001-12-24 Thread Brent Cowgill
It was pointed out to me: >Oracle: >> $dbh->do(CREATE SEQUENCE table_uid_seq START WITH 1 INCREMENT BY 1) >> $dbh->do(CREATE TABLE table ( uid NUMBER(10) PRIMARY KEY ... )) >> $dbh->do(INSERT INTO table (table_uid_seq.NEXTVAL, field...) VALUES (...)) >meanwhile someone else inserts some records

RE: To find a just-inserted record

2001-12-21 Thread Michael Peppler
Mitsuda, Alex writes: > Need to be a bit careful though, if there are "simultaneous" inserts going > on @@identity is not guaranteed to give back the correct key...besides a > numeric primary key, it's always good practice to have an alternate primary > key with which you can check against...

Re: To find a just-inserted record

2001-12-21 Thread Terrence Brannon
On Friday, December 21, 2001, at 12:55 PM, Brent Cowgill wrote: > most databases provide some > similar way of reading the last generated guid similarly to what > the sequence > numbers do for you in postgres and oracle. > > the last record inserted by process A may not be the last record ins

RE: To find a just-inserted record

2001-12-21 Thread Mitsuda, Alex
ssage- From: William R Ward [mailto:[EMAIL PROTECTED]] Sent: Friday, December 21, 2001 4:38 PM To: [EMAIL PROTECTED] Subject: Re: To find a just-inserted record [EMAIL PROTECTED] (Chris Spurgeon) writes: > Another data point for this discussion if you're connecting to a > Microso

Re: To find a just-inserted record

2001-12-21 Thread William R Ward
[EMAIL PROTECTED] (Chris Spurgeon) writes: > Another data point for this discussion if you're connecting to a > Microsoft Access Database via DBI, you can get the most recently created > primary key by using the @@identity value. Like this > > $sth = $dbh->prepare( 'select @@identi

RE: To find a just-inserted record

2001-12-21 Thread Chris Spurgeon
: Friday, December 21, 2001 3:56 PM To: S P Arif Sahari Wibowo Cc: [EMAIL PROTECTED] Subject: Re: To find a just-inserted record Maybe you should post some table structures so we can see what you're doing. And what database you're using. If you are using a guid as the unique identifie

Re: To find a just-inserted record

2001-12-21 Thread Brent Cowgill
Maybe you should post some table structures so we can see what you're doing. And what database you're using. If you are using a guid as the unique identifier, most databases provide some similar way of reading the last generated guid similarly to what the sequence numbers do for you in postgres

Re: To find a just-inserted record

2001-12-21 Thread S P Arif Sahari Wibowo
On Fri, 21 Dec 2001, Brent Cowgill wrote: >It depends on the database driver you are connected to. All those solutions are using primary key. These solutions have several issues: - It require the table to have unique non null primary key. Not all table have primary key. - It require either th

RE: To find a just-inserted record

2001-12-21 Thread Sterin, Ilya
Depends on the database you are using? Ilya -Original Message- From: S P Arif Sahari Wibowo To: [EMAIL PROTECTED] Sent: 12/21/01 10:02 AM Subject: To find a just-inserted record Hi! Do you know how to make sure a perl script can found a record that the script just inserted? Say the pe

Re: To find a just-inserted record

2001-12-21 Thread Brent Cowgill
It depends on the database driver you are connected to. For example: MySQL: $dbh->do(CREATE TABLE table ( uid INT AUTO_INCREMENT PRIMARY KEY ... ) ) $dbh->do( INSERT INTO table (field...) VALUES (...)) using DBI, $unique_id = $dbh->{'mysql_insertid'}; Oracle: $dbh->do(CREATE SEQUENCE table_uid_se