row number with in cursor

Поиск
Список
Период
Сортировка
От Kevin Duffy
Тема row number with in cursor
Дата
Msg-id CAHCyeW1VwGD5JYX4GhHj-Yr3Tmupnrb_onm2BX+Vopb84=Tf1w@mail.gmail.com
обсуждение исходный текст
Ответы Re: row number with in cursor  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-sql
Hello All:

I need your kind assistance, to learn if it is possible
within a cursor to know what row you are on.
Something like this:

for currDateRate  IN  currDR( rate_in,  start_date )  LOOP

  raise notice ' currDateRate.rate_date: %', currDateRate.rate_date ;
  raise notice ' currDateRate.lag_r_value: %', currDateRate.lag_r_value ;
  raise notice ' currDateRate.rate_value: %', currDateRate.rate_value ;
  raise notice ' currDateRate.overnight_r: %', currDateRate.overnight_rate_return ;
  tr_index  :=  tr_index  *( 1+ currDateRate.overnight_rate_return  )  ;
  raise notice ' tr_index: %',tr_index ;
 -- this does NOT work
  raise notice ' row number %', currDateRate%ROWNUMBER ;
 
End LOOP;

for testing purposes would like to break out after twenty records.
Yes I know I could do a simple counter like this:

  rtn_cnt :=  rtn_cnt +1;
  if rtn_cnt  >= 20  then
      return  rtn_cnt;
  END IF;   


thamks for your attention to this matter

KD

В списке pgsql-sql по дате отправления:

Предыдущее
От: Bujji Babu
Дата:
Сообщение: Re: [BUGS] SQL Bug
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: row number with in cursor