![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm trying to perform this insert in a non-procedural environment: INSERT INTO table (column1, column2) SELECT :col1value, MAX(column2) + :count FROM table WHERE column1 = :col1value ; My problem is that two or more processes might be executing this statement concurrently. If so, they could get the same value for MAX(column2). But I want the second process to get the updated value for that aggregate that is set by the first process, and insert an incremented value based on THAT. Is there a way I can write this statement so one instance locks out the second one? In my environment, one statement is all I'm allowed. Thanks, Elliott |
#3
| |||
| |||
|
|
Use a sequence replace the horrible expression by sequence>.nextval and you are set. Sybrand Bakker Senior Oracle DBA |
#4
| |||
| |||
|
|
Use a sequence replace the horrible expression by sequence>.nextval and you are set. Sybrand Bakker Senior Oracle DBA Would that I could. Unfortunately, the business requirements are that I know the generated values in advance of inserting them. I've thought of establishing an intermediate table into which I could insert the values from a sequence, together with other record identifying information, to be used in a lookup later. But I'm dealing with, in some cases, a couple of million rows per run, with a dozen runs a day. You can write me at eshevin (AT) ford (DOT) com if you'd care to hear more. |
![]() |
| Thread Tools | |
| Display Modes | |
| |