Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> SQL question (using result of nested statement in arithmetic operation)

SQL question (using result of nested statement in arithmetic operation)

From: Stephan Grimm <stephan.grimm_at_igd.fhg.de>
Date: Fri, 25 Apr 2003 16:56:52 +0200
Message-ID: <3EA94CB4.DAC5C024@igd.fhg.de>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US