title: how to include isolation level in psql function
body: <pre><code>    CREATE OR REPLACE FUNCTION createNewOrder(userID text,currency text,orderAmount integer,price integer,isSell boolean,fast boolean) RETURNS integer AS $$
      DECLARE 
      asset record;
      newBalance integer;
      pairKey text;
      begin SET TRANSACTION ISOLATION LEVEL REPEATABLE READ READ write;
      --get user asset :
      select into asset getUserAssetEntity(userID);
      --check if asset not found :
      if not found then 
      rollback;
      return 101;
      end if;
  
      pairKey= asset.currency+"_payable" ;
      --check if asset is enoughf : 
      if pairKey &gt;= orderAmount then 
      --create order  
      insert into public.order (pair,amount,price,remain,cdate,sell,cancel,fast,traderid,isactive,status)
      values (currency,orderAmount,price,orderAmount,NOW(),isSell,false,userID,true,"alive");
  
      --calculate new Balance :
  
      newBalance=asset.asset.pairKey - orderAmount;
  
      --update user asset :
      update public.asset set asset.pairKey = newBalance where id=asset.id;
  
      commit;
      return 103;
  
      else 
      rollback;
      return 102;
      end if;
  
      END; $$ 
      LANGUAGE 'plpgsql';
  </code></pre>
  
  <hr>
  
  <p>I tried to use isolation level in my function and It returns this error:</p>
  
  <blockquote>
    <p>error: SET TRANSACTION ISOLATION LEVEL must be called before any query</p>
  </blockquote>