By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,661 Members | 781 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,661 IT Pros & Developers. It's quick & easy.

Understanding End of Cursor?

P: 7
Hi all;
How can i catch end of the cursor?
Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE FUNCTION "public"."fnc_rapthsbordro" (bastar date, bittar date, basmuk integer, bitmuk integer, basmak varchar, bitmak varchar, siralama varchar, tip boolean) RETURNS varchar AS
  2. $body$
  3. declare intgelirkod integer;
  4. declare intgelirkod1 integer;
  5. declare  gelircurs   cursor for
  6.   select gelirkod_idno from tbl_gelirkodlari order by gelirkod_idno;
  7. begin
  8.  
  9. open gelircurs;
  10. fetch gelircurs into intgelirkod;
  11. while intgelirkod>0 loop
  12.  
  13.   intgelirkod1 = intgelirkod;
  14.  
  15.   fetch gelircurs into intgelirkod;
  16.  
  17.   if intgelirkod = intgelirkod1 then /* if previous */
  18.     intgelirkod = 0;
  19.   end if;
  20.  
  21. end loop;
  22.  
  23.  
  24. end;
  25. $body$
  26. LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
  27.  
i make something above. it is working because gelirkod_idno is pirmary key and unique. But may be the way to handle the fetch staus.
Best Regards..
Jul 30 '07 #1
Share this Question
Share on Google+
1 Reply


P: 7
i found it in this forum.
in loop
Expand|Select|Wrap|Line Numbers
  1.   exit when not found;
  2.  
tnks.
Jul 30 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.