Mikijs Posted February 14, 2008 Report Share Posted February 14, 2008 lietoju pgsql, bet ka lau uz pgsql dabunu funkciju mysql_insert_id? Link to comment Share on other sites More sharing options...
Mikijs Posted February 14, 2008 Author Report Share Posted February 14, 2008 Jau pats atradu. Vops ja kadam nakotne vajag tad Izveidojam CREATE SEQUENCE iepirkumi_sequence_id; un tad izveidojam kaut kadu tabulu CREATE TABLE iepirkumi ( id NUMERIC(10) NOT NULL DEFAULT nextval('iepirkumi_squence_id'), status NUMERIC(1,0), idnr VARCHAR(30) DEFAULT '-', kontaktpersona TEXT DEFAULT '-', idatums TIMESTAMP NOT NULL, pdatums TIMESTAMP, adatums TIMESTAMP, tdatums TIMESTAMP, prieksmets TEXT DEFAULT '-', uzvaretajs TEXT DEFAULT '-', icena FLOAT(2), isumma FLOAT(2), tips VARCHAR(30) DEFAULT 'iepirkumi', arhivetm NUMERIC(1,0) DEFAULT '0', PRIMARY KEY(id) ); un kad PHP janorada piemeram $id = mysql_insert_id(); mes rakstam $id = pg_query("SELECT last_value FROM iepirkumi"); Link to comment Share on other sites More sharing options...
Gints Plivna Posted February 14, 2008 Report Share Posted February 14, 2008 Savu mūžu neko neesmu darījis ar PostgreSQL, bet pieņemu, ka RETURNING klauza varētu būt kaut kas tas, ko Tu meklē. http://www.postgresql.org/docs/8.3/interac...sql-insert.html Kā es saprotu, tad postgresā arī ir sekvences, kuras izmanto, lai ģenerētu idus. http://www.postgresql.org/docs/8.3/interac...tesequence.html Gints Plivna http://datubazes.wordpress.com Link to comment Share on other sites More sharing options...
Kristabs Posted February 14, 2008 Report Share Posted February 14, 2008 ņjā... http://lv.php.net/manual/en/function.pg-last-oid.php Link to comment Share on other sites More sharing options...
Aleksejs Posted February 14, 2008 Report Share Posted February 14, 2008 Mikij, otrs SELECTS nav atomārs pasākums. Tas nozīmē, ka pa vidu starp tavu INSERT un tavu SELECT varēja izpildīties vēl kāds cits INSERT - un rezultātā Tu dabūtu pēdējā (bet ne sava) INSERTA vērtību. Link to comment Share on other sites More sharing options...
Valcha Posted February 15, 2008 Report Share Posted February 15, 2008 Kad Aleksejs tā pasaka, beidzot saprotu, kādēļ Oracle ir tāda šķietami bezjēdzīgi sarežģīta lieta kā sekvence. Tagad skaidrs :) Link to comment Share on other sites More sharing options...
Recommended Posts