title: EXEC SQL DECLARE variable in .h header files preprocessed by Oracle pro*c
body: <p>I am porting some C++ code with embedded SQL into a linux server with oracle database.</p>
  
  <p>The data Access Objects are C++ classes providing 
  .select()
  .insert()
  .findByPrimaryKey()
  etc, methods for database interactions.</p>
  
  <p>This is the testdao.h header file.</p>
  
  <pre><code>class TestDAO
  {
      private:
          EXEC SQL BEGIN DECLARE SECTION;
          int hv_col1;
          int hv_col2;
          .. .. upto 20 host variables ...
          EXEC SQL END DECLARE SECTION;
  
  public:
      testObj* select();
      bool insert(testObj);
      testObj* findByPrimaryKey(primaryKeyObj);
  }
  </code></pre>
  
  <p>This is testdao.ecpp file</p>
  
  <pre><code>class TestDAO::select()
  {
      ... select into hostvariables hv_col1, hv_col2 ..
      ... copy hostvariables data into object ...
  }
  
  class TestDAO::insert(testObj)
  {
      ... copy data from the testObj into hostvariables ... 
      ... EXEC SQL INSERT using hostvariales ...
  }
  
  class TestDAO::findByPrimaryKey(primaryKeyObj)
  {
      ... copy primaryKeyObj data into hostvariables ...
      ... EXEC SQL SELECT where primary key .. 
  }
  </code></pre>
  
  <p>Oracle pro*C precompiler can't handle EXEC SQL in header files. How do i declare the hostvariables so that I don't have to declare them repeatedly in each of the methods?</p>
  
  <p>I can't have them as global variables.</p>