On Wed, 2003-09-03 at 13:19, Martijn van Oosterhout wrote: > But your insert function needs to know something about the table it's > inserting into. The sequences have quite predicatable names. Besides, you > can set the name yourself (DCL does this IIRC). No it don't know anything about the table it insert into. I simply do the following :
1. INSERT data (comming from another layer) 2. Get the last oid 3. SELECT * FROM the same table where oid = what I just found. I know absolutly nothing about the table, and I like it this way :-) > The only thing you need to know is the name of the primary key field. This > many be a problem in a generic layer. If you like you can make a UNIQUE > INDEX on the oid column and retry inserts when they fail. Hmm, it all end up putting alot of information to a lower layer, and this is sad as PG already knows, but it may not tell me. > In your code, do create an index on the OID column? If not, that's be a > performance hit, I'm not sure what you mean ! > Something called CTID usually (AFAIK). It's a (block,tuple) pair. It changes > whenever you do an update. Or a vacuum. So no id for a row, but only for a row instance ? Is this the reason for the growing index files ? > If I were doing it would extract the primary key of each table on startup > and then change that one line of code to: > > os << "SELECT * FROM " << sTable << " WHERE " > << prikey << " = currval('" << sTable << "_" << prikey << "_seq')"; Thanks, but I have to be aware of the "prikey" name, and demand a prikey for all tables to insert row into :-( > Hope this helps, I know what you mean, but I don't like the impact of the solution. /BL ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html