Understanding End of Cursor?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AhmetYOL
    New Member
    • Jul 2007
    • 7

    Understanding End of Cursor?

    Hi all;
    How can i catch end of the cursor?
    Code:
    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
    $body$
    declare intgelirkod integer;
    declare intgelirkod1 integer;
    declare  gelircurs   cursor for
      select gelirkod_idno from tbl_gelirkodlari order by gelirkod_idno;
    begin
    
    open gelircurs;
    fetch gelircurs into intgelirkod;
    while intgelirkod>0 loop
    
      intgelirkod1 = intgelirkod;
    
      fetch gelircurs into intgelirkod;
    
      if intgelirkod = intgelirkod1 then /* if previous */
        intgelirkod = 0;
      end if;
    
    end loop;
    
    
    end;
    $body$
    LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
    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..
  • AhmetYOL
    New Member
    • Jul 2007
    • 7

    #2
    i found it in this forum.
    in loop
    Code:
      exit when not found;
    tnks.

    Comment

    Working...