Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Oracle i podział na podstrony
mroowa
post
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
  1. SELECT * FROM tabela WHERE STATUS = 'T' LIMIT 0, 20

a na następnej podstronie
  1. SELECT * FROM tabela WHERE STATUS = 'T' LIMIT 21, 20


Jak coś takiego zrobić na oracle, słyszałem coś o FETCH, ale nie wiem z czym to sie je (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)

Z góry dzięki za pomoc.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Blackhole
post
Post #2





Grupa: Zarejestrowani
Postów: 283
Pomógł: 1
Dołączył: 15.11.2004
Skąd: Mikołów

Ostrzeżenie: (0%)
-----


A dlaczeto takie zapytanie
  1. SELECT * FROM scott.emp WHERE ROWNUM <= 10 AND ROWNUM > 3
nie zwraca nic?
Go to the top of the page
+Quote Post
KILIUSZKIN
post
Post #3





Grupa: Zarejestrowani
Postów: 45
Pomógł: 0
Dołączył: 26.01.2006

Ostrzeżenie: (0%)
-----


Cytat(Blackhole @ 5.11.2006, 14:39:09 ) *
A dlaczeto takie zapytanie
  1. SELECT * FROM scott.emp WHERE ROWNUM <= 10 AND ROWNUM > 3
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:
  1. --------------
  2. SELECT
  3. rownum, column_1, column_2
  4. FROM table_1, table_2
  5. WHERE field_3 = 'some value'


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:
  1. SELECT
  2. column_1, column_2
  3. FROM table_1, table_2
  4. WHERE field_3 = 'some value' AND rownum > 5


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:
  1. SELECT
  2. column_1, column_2
  3. FROM ( SELECT
  4. rownum r_, column_1, column_2
  5. FROM table_1, table_2
  6. WHERE field_3 = 'some value'
  7. )
  8. WHERE r_ > 5
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 4.10.2025 - 13:48