title: LOCK TABLE can only be used in transaction blocks
body: <p>I am upgrading PostgreSQL from 8.1.3 to 9.2.9 for our product. We use unixODBC 2.2.11 to access database and it is written by C++ language. I got the following error after upgrade:</p>
  
  <pre><code>"LOCK TABLE can only be used in transaction blocks".
  </code></pre>
  
  <p>I checked the <a href="http://www.postgresql.org/docs/9.0/static/release-8-4.html" rel="nofollow">release note</a> for PostgreSQL and found it disallow LOCK TABLE outside a transaction block.</p>
  
  <p>I checked code and found we locked some tables in transation, sample code:</p>
  
  <pre><code>db_connect.BeginTrans();
  rtn_code = LockTable(db_connect, Setting_Filter.m_backup_tables, LOCK_SHARE);
  ...
  db_connect.Commit();
  </code></pre>
  
  <p>We use following api to create implicit transaction in BeginTrans():</p>
  
  <pre><code>int BeginTrans()
  {
      return SQLSetConnectAttr( m_ConHandle,SQL_ATTR_AUTOCOMMIT,(SQLPOINTER)SQL_AUTOCOMMIT_OFF, 0 );
  }
  </code></pre>
  
  <p>We execute the following lock table sql in LockTable() function: </p>
  
  <pre><code>lock table %s in share mode
  </code></pre>
  
  <p>My question is:</p>
  
  <ol>
  <li><p>Does this mean that the BeginTrans() doesn't create transaction successfully in Postgres 9.2?</p></li>
  <li><p>I notice that we often use 'BEGIN TRANSATION;' in PL/SQL, is there any corresponding API in unixODBC to start transaction explicitly?</p></li>
  </ol>