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 -> Re: SQL question (using result of nested statement in arithmetic operation)

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

From: Sybrand Bakker <gooiditweg_at_sybrandb.demon.nl>
Date: Fri, 25 Apr 2003 22:14:39 +0200
Message-ID: <vh5javsih8237dhqtki6bqjijbnhv4upss@4ax.com>


On 25 Apr 2003 11:16:18 -0700, 71062.1056_at_compuserve.com (--CELKO--) wrote:

>UPDATE Sequences
> SET seq_nbr = (SELECT MAX(seq_nbr)
> FROM sequences) + 1
> WHERE seq_id = :id;
>
>Without any DDL, I can only guess. It looks like you need a scalar
>subquery expression, but I have no idea what seq_nbr and seq_id mean
>since we have no DDL or specs for the table.

This solution is
a) syntactically incorrect
b) can not be used in a multi-user environment, as two different sessions may interfere with each other

You'll need to
select for update the record first (this will also lock the record), *without adding ANYTHING!!!*
update the table

Evidently this solution is still non-scalable, and shouldn't be used in an Oracle environment. the Op MUST encapsulate everything in a procedure and use proper sequences in Oracle.

Sybrand Bakker, Senior Oracle DBA

To reply remove -verwijderdit from my e-mail address Received on Fri Apr 25 2003 - 15:14:39 CDT

Original text of this message

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