pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedecpg and getting just assigned serial number
13+ messages / 8 participants
[nested] [flat]
* ecpg and getting just assigned serial number
@ 1999-09-12 14:25 Theofilu Andreas <theofilu@eunet.at>
1999-09-12 16:01 ` Re: [INTERFACES] ecpg and getting just assigned serial number Tom Lane <tgl@sss.pgh.pa.us>
1999-09-13 08:27 ` Re: [INTERFACES] ecpg and getting just assigned serial number Michael Meskes <meskes@postgresql.org>
0 siblings, 2 replies; 13+ messages in thread
From: theofilu@eunet.at @ 1999-09-12 14:25 UTC (permalink / raw)
To: pgsql-interfaces
-----BEGIN PGP SIGNED MESSAGE-----
Hi to all,
I've written a small application first based on Informix and trying to
implement now support for PostgreSQL. I was mostly successful, but there is
still one problem left.
I'm using 'ecpg' to develop my application, because it's mostly compatible
to Informix's 'esqlc'. However. I have a table with a field of type
'serial'. Now I've no problem to insert any sentences into this table, but
immediately after inserting a new sentence I need the newly assigned number
to the serial field in the table. How can I access this number?
With Informix I got this number in a field of structure 'sqlca'. With
PostgreSQL the same field in this structure exists but contains always 0,
as documented.
- --
Theofilu Andreas
http://members.eunet.at/theofilu
-------------------------------------------------
Enjoy the science of Linux!
Genieße die Wissenschaft von Linux!
-------------------------------------------------
-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: latin1
iQCVAwUBN9u302j/BcrYxhjVAQGr3gQAhlFZ6Uka/tfcEdSo85NG9Bzq6n4m70HW
f4lsECCTOm8EMCeKHvtJN7t5IZ6PqHTquwkY3WpZpM8PPALRSHPlBtxJF+fI4RrB
dsQ0g02bwm71XgMNh4VLFYf9gttTOAQjxmA30WONIWoYngQIWr6u+7E6ihjOCdb0
BFPplhR5Vts=
=n75F
-----END PGP SIGNATURE-----
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: [INTERFACES] ecpg and getting just assigned serial number
1999-09-12 14:25 ecpg and getting just assigned serial number Theofilu Andreas <theofilu@eunet.at>
@ 1999-09-12 16:01 ` Tom Lane <tgl@sss.pgh.pa.us>
1999-09-13 13:03 ` Re: [INTERFACES] ecpg and getting just assigned serial number Bryan White <bryan@arcamax.com>
1 sibling, 1 reply; 13+ messages in thread
From: Tom Lane @ 1999-09-12 16:01 UTC (permalink / raw)
To: theofilu@eunet.at; +Cc: pgsql-interfaces
theofilu@eunet.at (Theofilu Andreas) writes:
> to Informix's 'esqlc'. However. I have a table with a field of type
> 'serial'. Now I've no problem to insert any sentences into this table, but
> immediately after inserting a new sentence I need the newly assigned number
> to the serial field in the table. How can I access this number?
Postgres doesn't return that number automatically; you'll have to run a
separate query to find out what was inserted. You could do something
like
select serialcolumn from table where oid = NNNN;
since a single-row insert does return the OID of the inserted row.
(Note this will be pretty slow if the table is big and does not have
an index on OID.)
Another possibility is to execute nextval() for yourself and then insert
that result explicitly when you create the row. Still takes two queries,
though.
regards, tom lane
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: [INTERFACES] ecpg and getting just assigned serial number
1999-09-12 14:25 ecpg and getting just assigned serial number Theofilu Andreas <theofilu@eunet.at>
1999-09-12 16:01 ` Re: [INTERFACES] ecpg and getting just assigned serial number Tom Lane <tgl@sss.pgh.pa.us>
@ 1999-09-13 13:03 ` Bryan White <bryan@arcamax.com>
0 siblings, 0 replies; 13+ messages in thread
From: Bryan White @ 1999-09-13 13:03 UTC (permalink / raw)
To: pgsql-interfaces
> theofilu@eunet.at (Theofilu Andreas) writes:
> > to Informix's 'esqlc'. However. I have a table with a field of type
> > 'serial'. Now I've no problem to insert any sentences into this table,
but
> > immediately after inserting a new sentence I need the newly assigned
number
> > to the serial field in the table. How can I access this number?
>
> Postgres doesn't return that number automatically; you'll have to run a
> separate query to find out what was inserted. You could do something
> like
> select serialcolumn from table where oid = NNNN;
> since a single-row insert does return the OID of the inserted row.
> (Note this will be pretty slow if the table is big and does not have
> an index on OID.)
>
> Another possibility is to execute nextval() for yourself and then insert
> that result explicitly when you create the row. Still takes two queries,
> though.
Another possibility is to "select currval('seqname')" where seqname is the
name of the sequence associated with the serial field. currval's are
maintained per connection so there are no multiuser problems. In many cases
you don't have retrieve the value but just use the expression is subsequent
statements.
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: [INTERFACES] ecpg and getting just assigned serial number
1999-09-12 14:25 ecpg and getting just assigned serial number Theofilu Andreas <theofilu@eunet.at>
@ 1999-09-13 08:27 ` Michael Meskes <meskes@postgresql.org>
1999-09-13 12:11 ` Re: [INTERFACES] ecpg and getting just assigned serial number Andreas Theofilu <theofilu@eunet.at>
1 sibling, 1 reply; 13+ messages in thread
From: Michael Meskes @ 1999-09-13 08:27 UTC (permalink / raw)
To: Theofilu Andreas <theofilu@eunet.at>; +Cc: pgsql-interfaces
On Sun, Sep 12, 1999 at 04:25:17PM +0200, Theofilu Andreas wrote:
> I'm using 'ecpg' to develop my application, because it's mostly compatible
> to Informix's 'esqlc'. However. I have a table with a field of type
> 'serial'. Now I've no problem to insert any sentences into this table, but
> immediately after inserting a new sentence I need the newly assigned number
> to the serial field in the table. How can I access this number?
> With Informix I got this number in a field of structure 'sqlca'. With
> PostgreSQL the same field in this structure exists but contains always 0,
> as documented.
Where exactly does Informix return it? sqlca[?].
Also does anyone know whether the backend returns that number somewhere?
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!
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: [INTERFACES] ecpg and getting just assigned serial number
1999-09-12 14:25 ecpg and getting just assigned serial number Theofilu Andreas <theofilu@eunet.at>
1999-09-13 08:27 ` Re: [INTERFACES] ecpg and getting just assigned serial number Michael Meskes <meskes@postgresql.org>
@ 1999-09-13 12:11 ` Andreas Theofilu <theofilu@eunet.at>
1999-09-14 18:32 ` Re: [INTERFACES] ecpg and getting just assigned serial number Michael Meskes <meskes@postgreSQL.org>
0 siblings, 1 reply; 13+ messages in thread
From: Andreas Theofilu @ 1999-09-13 12:11 UTC (permalink / raw)
To: Michael Meskes <meskes@postgresql.org>; +Cc: theofilu@eunet.at; pgsql-interfaces
Am Mo, 13 Sep 1999 schrieben Sie:
> On Sun, Sep 12, 1999 at 04:25:17PM +0200, Theofilu Andreas wrote:
> > I'm using 'ecpg' to develop my application, because it's mostly compatible
> > to Informix's 'esqlc'. However. I have a table with a field of type
> > 'serial'. Now I've no problem to insert any sentences into this table, but
> > immediately after inserting a new sentence I need the newly assigned number
> > to the serial field in the table. How can I access this number?
> > With Informix I got this number in a field of structure 'sqlca'. With
> > PostgreSQL the same field in this structure exists but contains always 0,
> > as documented.
>
> Where exactly does Informix return it? sqlca[?].
Informix returns this number in 'sqlca.sqlerrd[1]'. Currently this field
is not used by ecpg.
> Also does anyone know whether the backend returns that number somewhere?
Now I know that the backend does not return this number anywhere. Instead
you need two SQL commands to insert a sentence and get the number. You can
do it with following commands:
EXEC SQL nextval ('<sequence name>') into :variable;
EXEC SQL insert into <table> values (:variable, ...);
Maybe ecpg can implement the first call behind the scenes and put the new
serial number into 'sqlca.sqlerrd[1]'.
In Informix I have to write:
EXEC SQL insert into <table> values (0, ...);
The '0' increments the serial counter, who is a simple int4 field in a
system table, by one, inserts the sentence with new serial number into the
table and returns the new number in 'sqlca.sqlerrd[1]'.
It would be nice to have this feature exactly the same way with 'ecpg'.
This would make it more compatible, at least against Informix. Don't know
about Oracle.
BTW: When I insert a sentence in Informix and the serial field is not 0,
but contains a unique number and this number is higher than the current
value of the serial counter, the serial counter is set to the manualy set
number. This is important if one inserts sentences from a file. For
example when I move data between two machines/databases. With PostgreSQL
I've to set the counter into the sequence by hand, or it will not be
incremented.
--
Theofilu Andreas
http://members.eunet.at/theofilu
-------------------------------------------------
Enjoy the science of Linux!
Genieße die Wissenschaft von Linux!
-------------------------------------------------
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: [INTERFACES] ecpg and getting just assigned serial number
1999-09-12 14:25 ecpg and getting just assigned serial number Theofilu Andreas <theofilu@eunet.at>
1999-09-13 08:27 ` Re: [INTERFACES] ecpg and getting just assigned serial number Michael Meskes <meskes@postgresql.org>
1999-09-13 12:11 ` Re: [INTERFACES] ecpg and getting just assigned serial number Andreas Theofilu <theofilu@eunet.at>
@ 1999-09-14 18:32 ` Michael Meskes <meskes@postgreSQL.org>
1999-09-14 20:34 ` Re: [INTERFACES] ecpg and getting just assigned serial number Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 13+ messages in thread
From: Michael Meskes @ 1999-09-14 18:32 UTC (permalink / raw)
To: Andreas Theofilu <theofilu@eunet.at>; +Cc: Michael Meskes <meskes@postgreSQL.org>; pgsql-interfaces
On Mon, Sep 13, 1999 at 02:11:24PM +0200, Andreas Theofilu wrote:
> Informix returns this number in 'sqlca.sqlerrd[1]'. Currently this field
> is not used by ecpg.
Added to TODO. But I doubt this can easily be implemented.
> Maybe ecpg can implement the first call behind the scenes and put the new
> serial number into 'sqlca.sqlerrd[1]'.
No. ECPG does not interpret any command. They are just fed into the backend.
After an insert the backend returns the number of records inserted, but does
it also return the OID or whatever? I'm not sure but since an insert could
add more than one tuple I doubt that.
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!
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: [INTERFACES] ecpg and getting just assigned serial number
1999-09-12 14:25 ecpg and getting just assigned serial number Theofilu Andreas <theofilu@eunet.at>
1999-09-13 08:27 ` Re: [INTERFACES] ecpg and getting just assigned serial number Michael Meskes <meskes@postgresql.org>
1999-09-13 12:11 ` Re: [INTERFACES] ecpg and getting just assigned serial number Andreas Theofilu <theofilu@eunet.at>
1999-09-14 18:32 ` Re: [INTERFACES] ecpg and getting just assigned serial number Michael Meskes <meskes@postgreSQL.org>
@ 1999-09-14 20:34 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 13+ messages in thread
From: Tom Lane @ 1999-09-14 20:34 UTC (permalink / raw)
To: Michael Meskes <meskes@postgreSQL.org>; +Cc: Andreas Theofilu <theofilu@eunet.at>; pgsql-interfaces
Michael Meskes <meskes@postgreSQL.org> writes:
> After an insert the backend returns the number of records inserted, but does
> it also return the OID or whatever? I'm not sure but since an insert could
> add more than one tuple I doubt that.
If just one record is inserted, then it returns the OID of that record.
regards, tom lane
^ permalink raw reply [nested|flat] 13+ messages in thread
* RE: [INTERFACES] ecpg and getting just assigned serial number
@ 1999-09-13 12:56 Ansley, Michael <Michael.Ansley@intec.co.za>
1999-09-13 13:46 ` RE: [INTERFACES] ecpg and getting just assigned serial number Andreas Theofilu <theofilu@eunet.at>
0 siblings, 1 reply; 13+ messages in thread
From: Ansley, Michael @ 1999-09-13 12:56 UTC (permalink / raw)
To: 'Andreas Theofilu' <theofilu@eunet.at>; Michael Meskes <meskes@postgreSQL.org>; +Cc: pgsql-interfaces
It's would be pretty difficult to return the unique key, because that is
defined by the user, and what if I had a table into which were placed values
from two separate sequences (not great design, but possible), or a compound
unique key, or multiple unique keys? The things that's necessary here is
for the sqlca struct to contain the oid of the newly inserted row after the
insertion. Of course, then there is a problem if more than one row is
inserted. What does Informix do then?
But why can't you just write a database function that performs the insert,
and returns the value, and then call the function using embedded sql. The
function can be written in plsql, and accept as parameters all the values
that need to go into the new record. This is far better db design.
The basic function looks like this (pseudocode):
BEGIN
get next sequence value into i;
insert new record using parameters and i;
if insert fails then
return (0);
else
return (i);
END
This has the added benefit of being able to add further business rules into
the function, which better encapsulates your process. Of course, this is
design dependent, but it's a method I've used quite successfully in the past
(although, admittedly, not in PG ;-)
MikeA
>> -----Original Message-----
>> From: Andreas Theofilu [mailto:theofilu@eunet.at]
>> Sent: Monday, September 13, 1999 2:11 PM
>> To: Michael Meskes
>> Cc: theofilu@eunet.at; pgsql-interfaces@postgreSQL.org
>> Subject: Re: [INTERFACES] ecpg and getting just assigned
>> serial number
>>
>>
>> Am Mo, 13 Sep 1999 schrieben Sie:
>> > On Sun, Sep 12, 1999 at 04:25:17PM +0200, Theofilu Andreas wrote:
>> > > I'm using 'ecpg' to develop my application, because it's
>> mostly compatible
>> > > to Informix's 'esqlc'. However. I have a table with a
>> field of type
>> > > 'serial'. Now I've no problem to insert any sentences
>> into this table, but
>> > > immediately after inserting a new sentence I need the
>> newly assigned number
>> > > to the serial field in the table. How can I access this number?
>> > > With Informix I got this number in a field of structure
>> 'sqlca'. With
>> > > PostgreSQL the same field in this structure exists but
>> contains always 0,
>> > > as documented.
>> >
>> > Where exactly does Informix return it? sqlca[?].
>>
>> Informix returns this number in 'sqlca.sqlerrd[1]'.
>> Currently this field
>> is not used by ecpg.
>>
>> > Also does anyone know whether the backend returns that
>> number somewhere?
>>
>> Now I know that the backend does not return this number
>> anywhere. Instead
>> you need two SQL commands to insert a sentence and get the
>> number. You can
>> do it with following commands:
>>
>> EXEC SQL nextval ('<sequence name>') into :variable;
>> EXEC SQL insert into <table> values (:variable, ...);
>>
>> Maybe ecpg can implement the first call behind the scenes
>> and put the new
>> serial number into 'sqlca.sqlerrd[1]'.
>> In Informix I have to write:
>>
>> EXEC SQL insert into <table> values (0, ...);
>>
>> The '0' increments the serial counter, who is a simple int4
>> field in a
>> system table, by one, inserts the sentence with new serial
>> number into the
>> table and returns the new number in 'sqlca.sqlerrd[1]'.
>> It would be nice to have this feature exactly the same way
>> with 'ecpg'.
>> This would make it more compatible, at least against
>> Informix. Don't know
>> about Oracle.
>>
>> BTW: When I insert a sentence in Informix and the serial
>> field is not 0,
>> but contains a unique number and this number is higher than
>> the current
>> value of the serial counter, the serial counter is set to
>> the manualy set
>> number. This is important if one inserts sentences from a file. For
>> example when I move data between two machines/databases.
>> With PostgreSQL
>> I've to set the counter into the sequence by hand, or it will not be
>> incremented.
>> --
>> Theofilu Andreas
>> http://members.eunet.at/theofilu
>>
>> -------------------------------------------------
>> Enjoy the science of Linux!
>> Genieße die Wissenschaft von Linux!
>> -------------------------------------------------
>>
>> ************
>>
^ permalink raw reply [nested|flat] 13+ messages in thread
* RE: [INTERFACES] ecpg and getting just assigned serial number
1999-09-13 12:56 RE: [INTERFACES] ecpg and getting just assigned serial number Ansley, Michael <Michael.Ansley@intec.co.za>
@ 1999-09-13 13:46 ` Andreas Theofilu <theofilu@eunet.at>
1999-09-13 18:49 ` RE: [INTERFACES] ecpg and getting just assigned serial number Craig Orsinger <orsingerc@epg-gw1.lewis.army.mil>
0 siblings, 1 reply; 13+ messages in thread
From: Andreas Theofilu @ 1999-09-13 13:46 UTC (permalink / raw)
To: pgsql-interfaces; +Cc: theofilu@eunet.at
Am Mo, 13 Sep 1999 schrieben Sie:
> It's would be pretty difficult to return the unique key, because that is
> defined by the user, and what if I had a table into which were placed values
> from two separate sequences (not great design, but possible), or a compound
> unique key, or multiple unique keys? The things that's necessary here is
> for the sqlca struct to contain the oid of the newly inserted row after the
> insertion. Of course, then there is a problem if more than one row is
> inserted. What does Informix do then?
Agree. It's difficult to do that with PostgreSQL. It works with Informix
only because the type 'serial' is realy a seperate type and handled
completely different. Beside this it's allowed to have only one field of
type serial in a table. With SQL command 'insert' you can only insert one
sentence at a time. To enter more than one sentence you must program a
loop. So I can see no problem with the serial number. Beside this: The
serial field of Informix is independant of any index. Therefore it doesn't
matter how complicate an index may be.
> But why can't you just write a database function that performs the insert,
> and returns the value, and then call the function using embedded sql. The
> function can be written in plsql, and accept as parameters all the values
> that need to go into the new record. This is far better db design.
I can write such a function, of course. But I will not break compatibility
to Informix, because both databases, PostgreSQL _and_ Informix are
supported in only a single source file.
> The basic function looks like this (pseudocode):
>
> BEGIN
> get next sequence value into i;
> insert new record using parameters and i;
> if insert fails then
> return (0);
> else
> return (i);
> END
>
> This has the added benefit of being able to add further business rules into
> the function, which better encapsulates your process. Of course, this is
> design dependent, but it's a method I've used quite successfully in the past
> (although, admittedly, not in PG ;-)
I've done exactly the same your example shows, but not in a seperate
function. I simply added one SQL command to get the next number out of the
sequence. This works well now and the extra line is ignored when compiling
for Informix :-).
--
Theofilu Andreas
http://members.eunet.at/theofilu
-------------------------------------------------
Enjoy the science of Linux!
Genieße die Wissenschaft von Linux!
-------------------------------------------------
^ permalink raw reply [nested|flat] 13+ messages in thread
* RE: [INTERFACES] ecpg and getting just assigned serial number
1999-09-13 12:56 RE: [INTERFACES] ecpg and getting just assigned serial number Ansley, Michael <Michael.Ansley@intec.co.za>
1999-09-13 13:46 ` RE: [INTERFACES] ecpg and getting just assigned serial number Andreas Theofilu <theofilu@eunet.at>
@ 1999-09-13 18:49 ` Craig Orsinger <orsingerc@epg-gw1.lewis.army.mil>
1999-09-14 18:23 ` Re: [INTERFACES] ecpg and getting just assigned serial number Michael Meskes <meskes@postgresql.org>
0 siblings, 1 reply; 13+ messages in thread
From: Craig Orsinger @ 1999-09-13 18:49 UTC (permalink / raw)
To: Andreas Theofilu <theofilu@eunet.at>; +Cc: pgsql-interfaces
On 13-Sep-99 Andreas Theofilu wrote:
> I can write such a function, of course. But I will not break compatibility
> to Informix, because both databases, PostgreSQL _and_ Informix are
> supported in only a single source file.
I've tried to do this myself, and in the long run I think
you'll be better off planning on having two different versions of
embedded C, or at least, two different sets of functions that do
certain operations. Informix ESQL/C and ecpg have significantly
different syntax, especially regarding CURSORs and FETCHs. If you
keep things simple, and have some way of converting database names
between the two systems, you can undoubtedly do what you're trying
to do. Anything else and it gets really difficult. While Informix
supports EXEC SQL IFDEF, PostgreSQL does not appear to.
An alternative might be to have a single source file that
can be modified by a sed or awk script to conform to whatever
embedded SQL you're using at the moment. I considered this approach,
but didn't pursue it because I didn't have the time.
We had a discussion here about this subject in June. The
subject was "esql/c documentation". If you can't find it in the
archive, I can e-mail some of the more interesting posts in that
thread.
----------------------------------
Date: 13-Sep-99 Time: 10:55:47
Craig Orsinger (email: <orsingerc@epg-gw1.lewis.army.mil>)
Logicon RDA
Bldg. 8B28 "Just another megalomaniac with ideas above his
6th & F Streets station. The Universe is full of them."
Ft. Lewis, WA 98433 - The Doctor
----------------------------------
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: [INTERFACES] ecpg and getting just assigned serial number
1999-09-13 12:56 RE: [INTERFACES] ecpg and getting just assigned serial number Ansley, Michael <Michael.Ansley@intec.co.za>
1999-09-13 13:46 ` RE: [INTERFACES] ecpg and getting just assigned serial number Andreas Theofilu <theofilu@eunet.at>
1999-09-13 18:49 ` RE: [INTERFACES] ecpg and getting just assigned serial number Craig Orsinger <orsingerc@epg-gw1.lewis.army.mil>
@ 1999-09-14 18:23 ` Michael Meskes <meskes@postgresql.org>
0 siblings, 0 replies; 13+ messages in thread
From: Michael Meskes @ 1999-09-14 18:23 UTC (permalink / raw)
To: Craig Orsinger <orsingerc@epg-gw1.lewis.army.mil>; +Cc: Andreas Theofilu <theofilu@eunet.at>; pgsql-interfaces
On Mon, Sep 13, 1999 at 11:49:03AM -0700, Craig Orsinger wrote:
> to do. Anything else and it gets really difficult. While Informix
> supports EXEC SQL IFDEF, PostgreSQL does not appear to.
Not yet, but it may make a nice addition.
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!
^ permalink raw reply [nested|flat] 13+ messages in thread
* RE: [INTERFACES] ecpg and getting just assigned serial number
@ 1999-09-15 07:50 Ansley, Michael <Michael.Ansley@intec.co.za>
1999-09-15 08:37 ` Re: [INTERFACES] ecpg and getting just assigned serial number Michael Meskes <meskes@postgresql.org>
0 siblings, 1 reply; 13+ messages in thread
From: Ansley, Michael @ 1999-09-15 07:50 UTC (permalink / raw)
To: 'Michael Meskes' <meskes@postgresql.org>; +Cc: pgsql-interfaces
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?
If anything is going to be returned in sqlca, it should only be the oid, at
least until Postgres gets a serial type (and probably after that as well),
and each table is guaranteed to only have one serial. In effect, that's
what the oid is, so if the insert returns the oid in sqlca, then you can
select based on the oid. Problem solved. And this is only for a single
insert (i.e. an insert with the VALUES keyword). For multiple inserts
(INSERT INTO <table> SELECT ...) this must be undefined, unless there is a
way of getting and returning all the oids, but I doubt it.
MikeA
>> -----Original Message-----
>> From: Michael Meskes [mailto:meskes@postgresql.org]
>> Sent: Tuesday, September 14, 1999 8:32 PM
>> To: Andreas Theofilu
>> Cc: Michael Meskes; pgsql-interfaces@postgresql.org
>> Subject: Re: [INTERFACES] ecpg and getting just assigned
>> serial number
>>
>>
>> On Mon, Sep 13, 1999 at 02:11:24PM +0200, Andreas Theofilu wrote:
>> > Informix returns this number in 'sqlca.sqlerrd[1]'.
>> Currently this field
>> > is not used by ecpg.
>>
>> Added to TODO. But I doubt this can easily be implemented.
>>
>> > Maybe ecpg can implement the first call behind the scenes
>> and put the new
>> > serial number into 'sqlca.sqlerrd[1]'.
>>
>> No. ECPG does not interpret any command. They are just fed
>> into the backend.
>>
>> After an insert the backend returns the number of records
>> inserted, but does
>> it also return the OID or whatever? I'm not sure but since
>> an insert could
>> add more than one tuple I doubt that.
>>
>> 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!
>>
>> ************
>>
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: [INTERFACES] ecpg and getting just assigned serial number
1999-09-15 07:50 RE: [INTERFACES] ecpg and getting just assigned serial number Ansley, Michael <Michael.Ansley@intec.co.za>
@ 1999-09-15 08:37 ` Michael Meskes <meskes@postgresql.org>
0 siblings, 0 replies; 13+ messages in thread
From: Michael Meskes @ 1999-09-15 08:37 UTC (permalink / raw)
To: Ansley, Michael <Michael.Ansley@intec.co.za>; +Cc: 'Michael Meskes' <meskes@postgresql.org>; pgsql-interfaces
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!
^ permalink raw reply [nested|flat] 13+ messages in thread
end of thread, other threads:[~1999-09-15 08:37 UTC | newest]
Thread overview: 13+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-09-12 14:25 ecpg and getting just assigned serial number Theofilu Andreas <theofilu@eunet.at>
1999-09-12 16:01 ` Tom Lane <tgl@sss.pgh.pa.us>
1999-09-13 13:03 ` Bryan White <bryan@arcamax.com>
1999-09-13 08:27 ` Michael Meskes <meskes@postgresql.org>
1999-09-13 12:11 ` Andreas Theofilu <theofilu@eunet.at>
1999-09-14 18:32 ` Michael Meskes <meskes@postgreSQL.org>
1999-09-14 20:34 ` Tom Lane <tgl@sss.pgh.pa.us>
1999-09-13 12:56 RE: [INTERFACES] ecpg and getting just assigned serial number Ansley, Michael <Michael.Ansley@intec.co.za>
1999-09-13 13:46 ` Andreas Theofilu <theofilu@eunet.at>
1999-09-13 18:49 ` Craig Orsinger <orsingerc@epg-gw1.lewis.army.mil>
1999-09-14 18:23 ` Michael Meskes <meskes@postgresql.org>
1999-09-15 07:50 RE: [INTERFACES] ecpg and getting just assigned serial number Ansley, Michael <Michael.Ansley@intec.co.za>
1999-09-15 08:37 ` Michael Meskes <meskes@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox