Well you where correct, this is the answer of a metalink user:
user_seq.CURRVAL (with two R's) is the last number that was assigned in your
session. Even if records are added in other sessions, your CURRVAL remains
the same. Try it. Open two SQL*Plus windows (you can even use the same
username) a
In PL/SQL:
DECLARE
new_user_id NUMBER;
BEGIN
INSERT INTO users ( user_id, user_name ) VALUES ( user_seq.NEXTVAL,
'userName' ) RETURNING user_id INTO new_user_id;
END;
So, similarly (though a little bit of a hack), in JDBC (since
generatedKeys() or whatever they call it isn't supporte
Not Albert, but thanks, you have give me more solutions than in the metalink
foro of oracle, thanks!! Another solution, to do only one sentence, I do´nt
want to obtain the userCode of an insert sentence that occur between the
insert and the select user_seq.curval from dual, any other solution ??
Daniel,
If you are by chance using iBatis, look at their selectKey command. It
is the one that seems to be referred to most for this type of need on
the iBatis list. If not, sorry.
Al
Brett Connor wrote:
(In case my reply to completely the wrong post didn't get read!...)
selecting max...
(In case my reply to completely the wrong post didn't get read!...)
selecting max... isn't a viable solution, because of other sessions as you say.
Assuming you're at least using Java, you might want to look at
java.sql.Statement.getGeneratedKeys()
Oracle database returns generated keys in the '
Thanks
so, first:
insert into users_values (user_seq .nextval, 'userName');
and then:
select user_seq.curval from dual
There is not a way to make only one sentence to do that? Like in SQL 2000:
SET NOCOUNT ON INSERT INTO
USER_VALUES
(USER_NAME)
VALUES
Use curval to obtain the last selected value for the current oracle
session. Note that you cannot access curval until nextval has been used
at least once in the current oracle session.
select user_seq.curval
from dual
Daniel Chacón Sánchez wrote:
Hi I know this the struts mail list, but I have
Hi I know this the struts mail list, but I have a question and I hope that
someone know the answer
I'm using an oracle database, I have a sequence to obtain the nextval that
will be the key of the row that I will insert, after the insert I need to
know which is that value so I can tell the user w
8 matches
Mail list logo