When using Oracle, there is no top this property, and if you want to limit the number of queries, you must use a pseudo-field rownum
You can see that the first column without title in this field is the RowNum field, which comes in when Oracle inserts the data, without needing to be added manually.
We can take advantage of this field if we want to implement the number of control queries.
Programme one:
We can write
SELECT * from Ta_ News WHERE<=3ORDERbyDESC
To control the display of three records.
However, we notice that this rownum is generated when inserting data, which means that if we insert a new piece of news that is earlier than 3rd, he will also appear in the last one, so that the rownum<3 will not be retrieving the newly added data.
So we need to use subqueries to solve this problem.
Scenario Two:
We write it down.
SELECT * from SELECT * from Ta_ news ORDER by DESC ) WHERE<= 3 ORDERbyASC ;
So our query is actually a temporary table (the results in parentheses are returned as a new table), the rownum of this table is sorted according to the "release time" in reverse order, we then rownum the outer layer of the filter to get the desired results.
The above describes the principle of SQL, then how to use it in ASP.
Friends who have tried will find that the subquery is not running in the dataset, then we need to edit the stored procedure to solve the problem.
Create or Replace procedureShow News list (P_ show number of barsint, P_result out Sys_refcursor) asbegin OPENP_result for SELECT * from ( SELECT * fromTa_ NewsORDER byRelease timeDESC) WHEREROWNUM<=p_ Display number of barsORDER byROWNUMASC;EndDisplay the news list;
The above stored procedures only pass a parameter is the actual bar number, so that the user can only display the number of bar input to the corresponding bar number of news, and the time in reverse order, so that users see is always the latest several news.
The second parameter here
is an out-of-shape parameter that returns a cursor. (a cursor is actually a table that has the result as a table in the cursor and as the return value).
By writing this stored procedure and then dragging it into the dataset, you can bind the method with ObjectDataSource as a table. This allows you to control the number of display bars by using the repeater binding ObjectDataSource.
Resolving display quantity control for Repeater controls in ASP.