Using php & postgresql, I have 2 tables and a sequence as follows: create sequence serial;
CREATE TABLE glmaster ( id int default nextval('serial'), accno char(6) constraint accno_con not null unique, reportlevel int, name text, isheader boolean default 'f', isdebit boolean not null, inactive boolean default 'f', primary key (id) ); CREATE TABLE glcheque ( id int references glmaster, primary key(id) ); My problem is this, when inserting to glmaster, at times I want to also insert the same value of id into glcheque. The values originate in a form generated using php. My first attempt was to insert all values except id into glmaster then followed by (in php): $sql = select id as glid from glmaster where accno = $glaccno; pg_exec($dbcon, $sql); then $sql1 = insert into glcheque values ($glid); etc that fails because $glid is not initialised. My next attempt was '$sql = select nextval ('serial') as glid;' etc Neither does this initialise $glid. I'm not sure if this is simply a timing problem, or if there is something wrong with my logic. Thanks for any help given Bob Parker -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php