I'm trying to use a variable from a cursor in the select statement of another cursor in pl/sql
<p>I need to run a query that finds me the first 20 vehicles that are as close to another vehicle with specific terms. I'm writing this in SQL Developer on an oracle database.</p>

<p>Here's what I have so far: </p>

<pre><code>DECLARE
    TYPE cur_type IS REF CURSOR;

    CURSOR lost_vehicles_cur IS
       select 
          v.vin,
          V.VEHICLE_ID
       from d_vehicles V
       where v.system_id =4  ;

    make_cur cur_type;
    l_cur_string VARCHAR2(2000);
    l_make  &lt;type&gt;;
    l_model &lt;type&gt;;
    l_vin &lt;type&gt;;
BEGIN
    FOR vehicle IN lost_vehicles_cur LOOP
        dbms_output.put_line('lost vehicle is  '|| vehicle.vehicle_id);
        l_cur_string := 'SELECT make_name, model_name,vin FROM vehicles where make=(select make from vehicles where vehicle_id= '
            ||  vehicle.vehicle_id || 'and rownum&lt;=20 and system_id=3 and vehicle_status_id in (13,14) ';
        OPEN make_cur FOR l_cur_string;
        LOOP
            FETCH make_cur INTO l_make, l_model, L_vin;
            EXIT WHEN make_cur%NOTFOUND;
            dbms_output.put_line('Related vehicles are ' || l_make || l_model || L_vin);
        END LOOP;
        CLOSE make_cur;
    END LOOP;
END;
</code></pre>

<p>I used a previous answer to get to this however I get the following error when I run this:</p>

<blockquote>
  <p>ORA-06550: line 32, column 13: PLS-00103: Encountered the symbol "&lt;" when expecting one of the following: constant exception   table long double ref char time timestamp interval date binary national character nchar 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. –</p>
</blockquote>