title: Oracle PL/SQL, I want to retrieve the details of the product which has the price closest to 4.23
body: <pre><code>create or replace procedure nearprice
  is
    userprice products.price%type := 4.23;
    closest   products.price%type;
    temp      products.price%type;
    tempid    products.pid%type;
    cursor procur is
      select * from products;
    prorec procur%rowtype;
  begin
    open procur;
    fetch procur into prorec;
    closest := abs(prorec.price - userprice);
    tempid  := prorec.pid;
  
    while procur%found then
    loop
      fetch procur into prorec;
      temp := abs(prorec.price - userprice);
      if temp &lt; closest then
        closest := temp;
        tempid = prorec.pid;  
      end if;
    end loop;
  
    close procur;
  
    select * 
      from products 
     where pid = tempid;
  
  end;
  </code></pre>
  
  <p>I want to retrieve the record in the <code>products</code> table which has the price closest to 4.23.
  'products' is a table with <code>pid</code> as primary key and datatype of price is number(*,2);
  In this procedure I try to find the minimum of the absolute value of the difference between 4.23 and the price, fetched by the cursor <code>prorec</code> and print all details corresponding to it. I keep getting </p>
  
  <blockquote>
    <p>Warning: Procedure created with compilation errors</p>
  </blockquote>
  
  <p>I'm new to PL/SQL so can anyone tell me what mistake I'm doing here? Thanks in advance.</p>