title: INSERT Mysql Micro Focus Cobol error 1064 if host variables used
body: <p>Getting error <code>-1064</code> while inserting into table using host variables. Works find if hard coded values used instead of host variables.</p>
  
  <p>Tried the same sql statement using hardcoded values as well as host variables. Changed picture clauses, used indicator variables etc for host variables but nothing works.</p>
  
  <p>Host variables declared:</p>
  
  <pre><code>   EXEC SQL BEGIN DECLARE SECTION END-EXEC.
     01 hfname  pic x(45).
     01 hlname  pic x(45).
     01 hdeptid pic S9(09) comp-4.
         EXEC SQL END DECLARE SECTION END-EXEC.
  </code></pre>
  
  <p>Code snippet below:</p>
  
  <pre><code>       EXEC SQL
             INSERT INTO employee (Fname, Lname, DeptId)
             VALUES ("abc", "def", 005)
         END-EXEC
         if sqlcode not = 0
             display sqlcode
             display sqlerrmc
             stop run
         end-if.
  </code></pre>
  
  <p>The above code works fine. The same code with variables instead of hard coded values as below gives the mentioned error:</p>
  
  <pre><code>       EXEC SQL
             INSERT INTO employee (Fname, Lname, DeptId)
             VALUES (:hfname, :hlname, :hdeptid)
         END-EXEC
  
         if sqlcode not = 0
             display sqlcode
             display sqlerrmc
             stop run
         end-if.
  </code></pre>
  
  <p>Not able to figure out why using host variables does not work. I have tried changing field lengths etc but nothing works. used simple pic 9(4) instead of s9(09) comp but does not work. Googled quite a bit but not many discussions on mysql cobol. Thanks for any help you can provide.</p>