Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> SQL question (using result of nested statement in arithmetic operation)
In order to emulate SEQUENCES with a table I would like to use something
like the following nested statement to read and at the same time
increase a number:
UPDATE sequences SET seq_number = ((SELECT seq_number FROM sequences WHERE seq_id = $id) + 1) WHERE seq_id = $id;
I guess the problem is that I try to use the result of a SELECT statement as operand for an arithmetic operation?! How can I get the number out of the subquery and increment it by 1 just like count() get's out a number of a result set ?
BTW: I need a solution that works with Oracle as well as MySQL using the same syntax!
Regards,
Stephan Grimm Received on Fri Apr 25 2003 - 09:56:52 CDT