The way we do this in OpenACS is to have a primary key in each table
that is populated from a sequence. So in your code you get the next
number from the sequence, do the insert (storing the number in the
primary key column), and then you have that number already in your
possession to use to reference the row.
janine
On Mar 28, 2006, at 11:58 AM, William Scott Jordan wrote:
Hi all!
Is there any way to get the oid or any other row identifier from a
database insert with ns_db on Postgres? Say for example I have the
following table:
CREATE TABLE test (
test_column int
) ;
And then I do an insert with aolserver, along the lines of:
ns_db dml $db "INSERT INTO test (test_column) SELECT COALESCE(MAX
(test_column),0) + 1 FROM test"
Because I don't know the value of test_column that I just entered,
I don't have any way to continue working with that entry. Is there
some trick to getting either the entry's oid or the value of
test_column back into the current TCL workspace?
Any suggestions would be appreciated.
-Scott
--
AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to
<[EMAIL PROTECTED]> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the
Subject: field of your email blank.
--
AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]>
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject:
field of your email blank.