![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am trying to do the following: EXEC SQL UPDATE MY TABLE SET COL1 = :newValue WHERE COL1 = 0 AND ROWNUM = 1 ORDER BY COL2; (index on COL1, COL2) Pro*C does not process the "ORDER BY" statement. How can I achieve the above Thanks Sandra |
#3
| |||
| |||
|
|
I am trying to do the following: EXEC SQL UPDATE MY TABLE SET COL1 = :newValue WHERE COL1 = 0 AND ROWNUM = 1 ORDER BY COL2; (index on COL1, COL2) Pro*C does not process the "ORDER BY" statement. How can I achieve the above Thanks Sandra |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
I am trying to do the following: EXEC SQL UPDATE MY TABLE SET COL1 = :newValue WHERE COL1 = 0 AND ROWNUM = 1 ORDER BY COL2; (index on COL1, COL2) Pro*C does not process the "ORDER BY" statement. How can I achieve the above Thanks Sandra |
#6
| |||
| |||
|
|
It appears that what you want to do is to update the row having the lowest value for col2 where col1=0. You could use this: UPDATE MY_TABLE SET col1 = :newValue WHERE col1 = 0 AND col2 = (SELECT MIN(col2) FROM MY_TABLE WHERE col1 = 0); |
#7
| |||
| |||
|
|
Thank you all for your help, I have one further question. It appears that what you want to do is to update the row having the lowest value for col2 where col1=0. You could use this: UPDATE MY_TABLE SET col1 = :newValue WHERE col1 = 0 AND col2 = (SELECT MIN(col2) FROM MY_TABLE WHERE col1 = 0); Yes, That is what I was trying do and only update a single row (in one statement). Could I do something like this: UPDATE MY_TABLE SET col1 = :newValue WHERE col2 = (SELECT MIN(col2) FROM MY_TABLE WHERE ROWNUM = 1 AND col1 = 0); If this is OK, I was wondering what are the performance implications of moving the "WHERE" clause to the outer update statement (index is on col2 as well), i.e.: UPDATE MY_TABLE SET col1 = :newValue WHERE col1 = 0 AND col2 = (SELECT MIN(col2) FROM MY_TABLE WHERE ROWNUM = 1); Thanks Sandra |
#8
| |||
| |||
|
|
Thank you all for your help, I have one further question. It appears that what you want to do is to update the row having the lowest value for col2 where col1=0. You could use this: UPDATE MY_TABLE SET col1 = :newValue WHERE col1 = 0 AND col2 = (SELECT MIN(col2) FROM MY_TABLE WHERE col1 = 0); Yes, That is what I was trying do and only update a single row (in one statement). Could I do something like this: UPDATE MY_TABLE SET col1 = :newValue WHERE col2 = (SELECT MIN(col2) FROM MY_TABLE WHERE ROWNUM = 1 AND col1 = 0); If this is OK, I was wondering what are the performance implications of moving the "WHERE" clause to the outer update statement (index is on col2 as well), i.e.: UPDATE MY_TABLE SET col1 = :newValue WHERE col1 = 0 AND col2 = (SELECT MIN(col2) FROM MY_TABLE WHERE ROWNUM = 1); Thanks Sandra |
#9
| |||
| |||
|
#10
| |||
| |||
|
|
UPDATE MY_TABLE SET COL1 = :NEWVALUE WHERE ROWID = (SELECT ROWID FROM MY_TABLE WHERE COL1 = 0 AND ROWNUM = 1 ORDER BY COL2) |
![]() |
| Thread Tools | |
| Display Modes | |
| |