title: SQR procedure with run-time error on BEGIN-SELECT statement
body: <p>Hello Stack community,</p>
  
  <p>I have been stuck for the past couple of days with what I initially thought was a relatively simple SQR update.</p>
  
  <p>In a nutshell, procedure Process-Main selects all the employees where COMPANY = 'ABC' and then I need to insert a record into TableA &amp; TableB associated with each employeeID</p>
  
  <p>TableB is empty, so I am simply running an INSERT statement for every empID and the records are being added without any problems.</p>
  
  <p>However, some empIDs might have existing records in TableA and I need to check for that before dong the INSERT into TableA.</p>
  
  <p>Oddly, when i execute this SQR, i'm getting the following error</p>
  
  <pre><code>(SQR 3721) Bad param found on 'BEGIN-SELECT' line;
  
  (SQR 3704) Missing procedure name.
      A.EMPLID
  </code></pre>
  
  <p>I'm fairly certain this is a syntax issue or i'm just having a brain fart... Does anyone have any advice/suggestions?</p>
  
  <p>Here's my pseudo code</p>
  
  <pre><code>!***************************
  begin-procedure Process-Main
  !***************************
  
  begin-select distinct
  
  J.DEPTID
  J.EMPLID
  J.EFFDT
  
  do Insert-TableA-Record
  do Insert-TableB-Record
  
  FROM PS_JOB J
  WHERE J.COMPANY = 'ABC'
  
  end-select
  end-procedure
  
  !****************************
  begin-procedure Insert-TableA-Record
  !****************************
  
  let $found = 'N'
  
  begin-select
      A.EMPLID
  
      let $found = 'Y'
  
      FROM TableA A
  
      WHERE A.EMPLID=&amp;J.EMPLID
      AND A.PLAN_TYPE='P1234'
  end-select
  
  if $found = 'N'
      begin-sql ON-ERROR = Abort-Update
          INSERT INTO TableA (
              EMPLID,
              PLAN_TYPE
          )
          VALUES (
              &amp;J.EMPLID,
              'P1234'
          );
      end-sql
  end-if
  
  end-procedure
  
  !****************************
  begin-procedure Insert-TableB-Record
  !****************************
  
  begin-sql ON-ERROR = Abort-Update
  
  !INSERT INTO TableB STMT HERE... 
  !everything runs fine in this procedure
  
  end-sql
  
  end-procedure
  </code></pre>