getting OID of INSERTed record in ECPG
getting OID of INSERTed record in ECPG
От:
Matthew Denny <mdenny@CS.Berkeley.EDU>
Дата:
Does anyone know how to get the OID of an INSERTed tuple when using PostgreSQL and ECPG? The documentation and the mail archives state that the OID of an INSERTed tuple is placed in sqlca.sqlerrd[1] after the SQL call. Although I can get sqlca to return error messages and error codes reliably in the same program, sqlca.sqlerrd[1] always equals 0 even after a successful insert. Has anyone had this same problem? I'm using the Linux binary distribution of PostgreSQL 6.5.3-3. Any possible solutions or workarounds would be greatly appreciated. thanks, Matt Denny
getting OID of INSERTed record in ECPG
От:
Matthew Denny <mdenny@CS.Berkeley.EDU>
Дата:
After sending the message below yesterday, I decided to look at the source to see where sqlca.sqlerrd[1] gets updated. From what I can tell, nowhere in ecpglib.c (or any other file) is sqlca.sqlerrd[1] even referenced much less updated. However, the documentation and a post to psql-interfaces (appended to the bottom of this email) seems to indicate that sqlca.sqlerrd[1] will hold the OID of an INSERTed tuple if a single tuple is inserted. Do I have the most up-to-date source and binaries? Here's what I have: source: postgresql-6.5.3.tar.gz (D/Led from postgresql.org) binaries: (Linux RPMs D/Led from postgresql.org) postgresql-6.5.3-3.rpm postgresql-server-6.5.3-3.rpm postgresql-6.5.3-3.rpm postgresql-devel-6.5.3-3.rpm postgresql-examples-1.0-1.rpm If there is any patches that I am missing here, any help would be greatly appreciated. Also, If anyone knows a workaround for getting the OID of a tuple INSERTed into a table, I would appreciate this as well. thanks in advance, Matt Denny Matthew Denny writes:> > Does anyone know how to get the OID of an INSERTed tuple when using> PostgreSQL and ECPG? The documentation and the mail archives state that the> OID of an INSERTed tuple is placed in sqlca.sqlerrd[1] after the SQL> call. Although I can get sqlca to return error messages and error> codes reliably in the same program, sqlca.sqlerrd[1] always equals 0> even after a successful insert. Has anyone had this same problem?> I'm using the Linux binary distribution of PostgreSQL 6.5.3-3. Any> possible solutions or workarounds would be greatly appreciated.> > thanks,> Matt Denny> > ;; message from psql-interfaces mentioned above On Wed, Sep 15, 1999 at 09:50:52AM +0200, Ansley, Michael wrote: > I don't think that a sequence number should be going into sqlca. This is > what it sounds like you are going to do, yes? But this wasn't what I meant. :-) I wasn't wording very well. What I wanted to say was that I don't see much of a chance to give back the serial as such. What I added to my TODO list (and btw just committed the changed source) is the return of the OID for the singleton insert. Michael -- Michael Meskes | Go SF 49ers! Th.-Heuss-Str. 61, D-41812 Erkelenz | Go Rhein Fire! Tel.: (+49) 2431/72651 | Use Debian GNU/Linux! Email: Michael@Fam-Meskes.De | Use PostgreSQL!
Re: getting OID of INSERTed record in ECPG
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Matthew Denny writes: > After sending the message below yesterday, I decided to look at the > source to see where sqlca.sqlerrd[1] gets updated. From what I can > tell, nowhere in ecpglib.c (or any other file) is sqlca.sqlerrd[1] > even referenced much less updated. However, the documentation and a > post to psql-interfaces (appended to the bottom of this email) seems > to indicate that sqlca.sqlerrd[1] will hold the OID of an INSERTed > tuple if a single tuple is inserted. Do I have the most up-to-date > source and binaries? Here's what I have: The post you quote is from Sep 99, so it's post-6.5.*. The feature you seek is in 7.0 ... regards, tom lane