February 6th, 2013, 04:23 AM
INSERT INTO statement and ordering the rows
I have a "Insert into" statement and i need the resulting table to be ordered by PRED_STUD_ID. The parameter values are defined somewhere in the code. Does anybody know how to achieve this? Here is what i have, but it's not stored by any order.
String sql = "INSERT INTO PREDMETSTUDENT (PRED_STUD_ID, PREDMETID, STUDENTID)"
+ "VALUES(:PRED_STUD_ID, :PREDMETID, :STUDENTID)";
OracleCommand cmd = new OracleCommand();
cmd.CommandText = sql;
cmd.Parameters.AddWithValue(":PRED_STUD_ID", predstud_id + 1);
February 6th, 2013, 08:32 AM
Ordering is done when you are retrieving data with a select query. You can't control the order that the rows are stored in.