Database updating sort order

Posted by / 19-Mar-2020 12:23

Database updating sort order

There are many ways in javascript to handle drag and drop. If you’d like to use something else there are three pieces of key information that need to be sent to the server: With this approach the server will do a total of three queries for every change to the display order no matter how many items are in the list.

Examples typically tell you to iterate over every item to do an update query to set the new order.

How can I achieve the above Thanks Sandra I am trying to do the following: EXEC SQLUPDATE MY TABLESET COL1 = :new Value WHERE COL1 = 0AND ROWNUM = 1ORDER BY COL2;(index on COL1, COL2)Pro*C does not process the "ORDER BY" statement.

Could I do something like this: UPDATE MY_TABLE SET col1 = :new Value 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 = :new Value WHERE col1 = 0 AND col2 = (SELECT MIN(col2) FROM MY_TABLE WHERE ROWNUM = 1); Thanks Sandra It appears that what you want to do is to update the row having the lowest value for col2 where col1=0.

Could I do something like this: UPDATE MY_TABLE SET col1 = :new Value 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 = :new Value WHERE col1 = 0 AND col2 = (SELECT MIN(col2) FROM MY_TABLE WHERE ROWNUM = 1); Thanks Sandra 1- Rownum doesn't buy you anything, other then ending the inner select after retreiving one row.

That row can be any row within your table - due to the random retreival by Oracle (will probably be the first physical row in the table, most of the time).

With that - returning only one row - why request the min(col2) - since you only have one row ?

database updating sort order-46database updating sort order-5database updating sort order-55

Is there any way I can achieve what I need to do in SQL?

One thought on “database updating sort order”

  1. With over a decade of dating experience under our belts, lots of happy couples, and an award winning blog, we must be doing something right! ) have my own library of books (2000) and films (900). i like intelligent, independent and gentle women who aren't seeking to change me. GSOH wicked at times, like to have fun and do different things.