![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 8 Pomógł: 0 Dołączył: 30.03.2005 Ostrzeżenie: (0%) ![]() ![]() |
Witam,
mam problem taki jak w temacie. Robie zapytanie do Oracle które zwraca mi dużo wyników, potrzebuje podzielić je na podstrony w php. Coś jak w MySQL
a na następnej podstronie
Jak coś takiego zrobić na oracle, słyszałem coś o FETCH, ale nie wiem z czym to sie je ![]() Z góry dzięki za pomoc. |
|
|
![]()
Post
#2
|
|
![]() Grupa: Zarejestrowani Postów: 740 Pomógł: 15 Dołączył: 23.08.2004 Skąd: Poznań Ostrzeżenie: (0%) ![]() ![]() |
http://www.softax.pl/prywatne/marcink/pora...racle/968783673
edit Specjalnie dla Ciebie fragment dokumentacji Pagination with ROWNUM My all-time-favorite use of ROWNUM is pagination. In this case, I use ROWNUM to get rows N through M of a result set. The general form is as follows: Kod select * from ( select /*+ FIRST_ROWS(n) */ a.*, ROWNUM rnum from ( your_query_goes_here, with order by ) a where ROWNUM <= :MAX_ROW_TO_FETCH ) where rnum >= :MIN_ROW_TO_FETCH; where
One important thing about using this pagination query is that the ORDER BY statement should order by something unique. If what you are ordering by is not unique, you should add something to the end of the ORDER BY to make it so. If you sort 100 records by SALARY, for example, and they all have the same SALARY value, then specifying rows 20 to 25 does not really have any meaning. In order to see this, use a small table with lots of duplicated ID values: Kod SQL> create table t 2 as 3 select mod(level,5) id, trunc(dbms_random.value(1,100)) data 4 from dual 5 connect by level <= 10000; Table created. And then query rows 148 to 150 and 151 after sorting by the ID column: Kod SQL> select * 2 from 3 (select a.*, rownum rnum 4 from 5 (select id, data 6 from t 7 order by id) a 8 where rownum <= 150 9 ) 10 where rnum >= 148; Kod ID DATA RNUM
------- ---------- ----------- 0 38 148 0 64 149 0 53 150 Ten post edytował bigZbig 17.10.2006, 13:48:41 -------------------- bigZbig (Zbigniew Heintze) | blog.heintze.pl
|
|
|
![]() ![]()
Post
#3
|
|
![]() Grupa: Zarejestrowani Postów: 283 Pomógł: 1 Dołączył: 15.11.2004 Skąd: Mikołów Ostrzeżenie: (0%) ![]() ![]() |
A dlaczeto takie zapytanie
nie zwraca nic? -------------------- Ściskam prawicę...
Jacek http://doscniewoli.pl/ - wszyscy jesteśmy niewolnikami bankierów! http://jezusimarlena.ovh.org/ YouTube - Egzorcyzmy Anneliese Michel |
|
|
![]()
Post
#4
|
|
![]() Grupa: Zarejestrowani Postów: 45 Pomógł: 0 Dołączył: 26.01.2006 Ostrzeżenie: (0%) ![]() ![]() |
A dlaczeto takie zapytanie nie zwraca nic? Rownum is a pseudo column. It numbers the records in a result set. The first record that meets the where criteria in a select statement is given rownum=1, and every subsequent record meeting that same criteria increases rownum. After issuing a select statement, one of the last steps that oracle does is to assign an increasing (starting with 1, increased by 1) number to each row returned. The value of this row number can always be queried with rownum in a select statement:
It is important to realize that the first row's rownum is always 1. This implies that the following query won't return a single row:
This is so because the first row would have to meet the following two mutually excluding criterias: rownum is 1 rownum is 6 (rownum > 5) In order to do this query in the (probably) intended spirit, a sub-query must be executed:
-------------------- ________________________________________________________________________________
czy programiści używają jeszcze diagramów ? jeśli nie, to tylko zwykli koderzy są ;) |
|
|
![]() ![]()
Post
#5
|
|
![]() Grupa: Zarejestrowani Postów: 283 Pomógł: 1 Dołączył: 15.11.2004 Skąd: Mikołów Ostrzeżenie: (0%) ![]() ![]() |
Dzięki.
A skąd wziąłeś to wyjaśnienie? -------------------- Ściskam prawicę...
Jacek http://doscniewoli.pl/ - wszyscy jesteśmy niewolnikami bankierów! http://jezusimarlena.ovh.org/ YouTube - Egzorcyzmy Anneliese Michel |
|
|
![]()
Post
#6
|
|
![]() Grupa: Zarejestrowani Postów: 45 Pomógł: 0 Dołączył: 26.01.2006 Ostrzeżenie: (0%) ![]() ![]() |
-------------------- ________________________________________________________________________________
czy programiści używają jeszcze diagramów ? jeśli nie, to tylko zwykli koderzy są ;) |
|
|
![]() ![]() |
![]() |
Aktualny czas: 19.08.2025 - 05:41 |