#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2008
    Posts
    12
    Rep Power
    0

    Two loop in store procedure can't work


    HI I have store porcedure. If I use one loop It is working When I use two loop It is not working. Error is on the begin line. What is the problem?
    thanks
    Code:
      
    
         FOR
          SELECT  VWKASA_TUR,  VWKASA_TUTAR, VWKASA_KAYITTARIH
          FROM VWKASAR1
          INTO :kasa_tur,  :kasa_tutar , :kasa_kayittarih do
          BEGIN
           
            FOR 
              SELECT ODEME_TIP FROM ODEME  DO
              BEGIN    /*Error is this line BEGIN*/      
               dyn = dyn  +  kasa_tutar;
               bakiye = dyn;
           
              END 
               suspend;
          END
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    25
    Rep Power
    0
    Originally Posted by AhmetNuri
    HI I have store porcedure. If I use one loop It is working When I use two loop It is not working. Error is on the begin line. What is the problem?
    thanks
    Code:
      
    
         FOR
          SELECT  VWKASA_TUR,  VWKASA_TUTAR, VWKASA_KAYITTARIH
          FROM VWKASAR1
          INTO :kasa_tur,  :kasa_tutar , :kasa_kayittarih do
          BEGIN
           
            FOR 
              SELECT ODEME_TIP FROM ODEME INTO var_ODEME_TIP DO
              BEGIN    /*Error is this line BEGIN*/      
               dyn = dyn  +  kasa_tutar;
               bakiye = dyn;
           
              END 
               suspend;
          END
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2008
    Posts
    12
    Rep Power
    0

    thanks


    thanks working code is

    Code:
    SET TERM ^ ;
    ALTER PROCEDURE PRYURKASAVW
    RETURNS (
        KASA_TUR varchar(20),
        KASA_KAYITTARIH date,
        KASA_TUTAR double precision,
        BAKIYE double precision,
        ODEME_TIP varchar(20) )
    AS
    DECLARE VARIABLE dyn DOUBLE PRECISION = 0.00;
    
    BEGIN
        bakiye = 0.00;
         FOR
          SELECT  VWKASA_TUR,  VWKASA_TUTAR, VWKASA_KAYITTARIH
          FROM VWKASAR1
          INTO :kasa_tur,  :kasa_tutar , :kasa_kayittarih do
          BEGIN
           
            FOR 
              SELECT ODEME_TIP FROM ODEME INTO :ODEME_TIP DO
              BEGIN      
                if (kasa_tur = ODEME_TIP) then
                begin
                  dyn = dyn  +  kasa_tutar;
                  bakiye = dyn;
                END 
              END 
               suspend;
          END
      /* Procedure body */
      SUSPEND;
    END^
    SET TERM ; ^
    
    
    GRANT EXECUTE
     ON PROCEDURE PRYURKASAVW TO  SYSDBA;

IMN logo majestic logo threadwatch logo seochat tools logo