Skip to main content

Hello guys. I try add fee for supplier by PL/SQL functions. But i get some errors and i dont know where is the problem.

 

DECLARE

  info_ VARCHAR2(32000) := NULL;
  attr_ VARCHAR2(32000);
  p1_   VARCHAR2(32000) := '';
  p2_   VARCHAR2(32000) := '';
  a_    NUMBER := 0;

  CURSOR get_data IS
    select p.SUPPLIER_ID
    from SUPPLIER_INFO_GENERAL p
    WHERE SUPPLIER_ID = '20040';
      
BEGIN
FOR rec_ IN get_data
  LOOP
    Client_Sys.Clear_Attr(attr_); 
    Client_Sys.Add_To_Attr('VENDOR_NO', rec_.supplier_id, attr_); 
    Client_Sys.Add_To_Attr('CONTRACT', 'RETIA', attr_);
    Client_Sys.Add_To_Attr('CHARGE_TYPE', 'DOPR + BAL', attr_); 
    Client_Sys.Add_To_Attr('CHARGE_BY_SUPPLIER', rec_.supplier_id, attr_);      
    IFSAPP.PURCHASE_CHARGE_SUPPLIER_API.NEW__(info_,p1_,p2_,attr_ ,'DO'); 

    a_ := a_ + 1;        
 END LOOP;
END;

 

 

ERROR what i get is 

 

Reset your variables within the Loop. Otherwise you will pass objid  and objversion (p1 and p2 for you) from the previously created Loop. The parameter is IN OUT so after the first Loop it WILL have a value.  

 

DECLARE

  info_ VARCHAR2(32000) := NULL;
  attr_ VARCHAR2(32000);
  p1_   VARCHAR2(32000);
  p2_   VARCHAR2(32000);
  a_    NUMBER := 0;

  CURSOR get_data IS
    select p.SUPPLIER_ID
    from SUPPLIER_INFO_GENERAL p
    WHERE SUPPLIER_ID = '20040';
      
BEGIN
FOR rec_ IN get_data
  LOOP
    Client_Sys.Clear_Attr(attr_);

    p1_ := Null;

    p2_ := Null;

    info_ := Null; 
    Client_Sys.Add_To_Attr('VENDOR_NO', rec_.supplier_id, attr_); 
    Client_Sys.Add_To_Attr('CONTRACT', 'RETIA', attr_);
    Client_Sys.Add_To_Attr('CHARGE_TYPE', 'DOPR + BAL', attr_); 
    Client_Sys.Add_To_Attr('CHARGE_BY_SUPPLIER', rec_.supplier_id, attr_);      
    IFSAPP.PURCHASE_CHARGE_SUPPLIER_API.NEW__(info_,p1_,p2_,attr_ ,'DO'); 

    a_ := a_ + 1;        
 END LOOP;
END;

 


You can use this;

 

DECLARE

  info_ VARCHAR2(32000) := NULL;
  attr_ VARCHAR2(32000);
  p1_   VARCHAR2(32000) := '';
  p2_   VARCHAR2(32000) := '';
  a_    NUMBER := 0;

BEGIN
  FOR rec_ IN (select SUPPLIER_ID
                 from SUPPLIER_INFO_GENERAL 
                WHERE SUPPLIER_ID = '20040') LOOP
    Client_Sys.Clear_Attr(attr_);
    Client_Sys.Add_To_Attr('VENDOR_NO', rec_.supplier_id, attr_);
    Client_Sys.Add_To_Attr('CONTRACT', 'RETIA', attr_);
    Client_Sys.Add_To_Attr('CHARGE_TYPE', 'DOPR + BAL', attr_);
    Client_Sys.Add_To_Attr('CHARGE_BY_SUPPLIER', rec_.supplier_id, attr_);
    IFSAPP.PURCHASE_CHARGE_SUPPLIER_API.NEW__(info_, p1_, p2_, attr_, 'DO');
  
    a_ := a_ + 1;
  END LOOP;
END;


Thanks guys, both version is good and it works. 


Reply