title: How do I call stored proc in DB2 using raw SQL (LINQPad)
body: <p>I have a stored procedure called <code>MY_STORED_PROC</code>.  It has an integer input parameter and an integer output parameter.</p>
  
  <p>I've tried all manner of <code>DECLARE</code>s, <code>BEGIN</code>s and <code>END</code>s and <code>call</code>s, and I've started to look into changing statement terminators (??), and I can't for the life of me get it to work in raw SQL (LINQPad in my case).</p>
  
  <p><a href="https://stackoverflow.com/a/11529261/614523">This answer</a> gives</p>
  
  <pre class="lang-sql prettyprint-override"><code>DECLARE outParam NUMBER;
  BEGIN
      TP.MY_STORED_PROC(26431414, outParam);
  END;
  </code></pre>
  
  <p>which returns </p>
  
  <blockquote>
    <p>ERROR [42601] [IBM][DB2/SUN64] SQL0104N  An unexpected token "DECLARE OUTPARAM NUMBER@ 
    BEGIN" was found following "
    ".  Expected tokens may include:  "<code>&lt;values&gt;</code>".</p>
  </blockquote>
  
  <p>I have also tried setting the terminator/delimeter:</p>
  
  <pre><code>--#SET DELIMITER @
  DECLARE outParam NUMBER@
  BEGIN
      TP.MY_STORED_PROC(26431414, outParam);
  END@
  
  --#SET TERMINATOR @
  DECLARE outParam NUMBER@
  BEGIN
      TP.MY_STORED_PROC(26431414, outParam);
  END@
  </code></pre>
  
  <p>both return </p>
  
  <blockquote>
    <p>ERROR [42601] [IBM][DB2/SUN64] SQL0104N  An unexpected token "DECLARE OUTPARAM NUMBER@ 
    BEGIN" was found following "
    ".  Expected tokens may include:  "<code>&lt;values&gt;</code>".</p>
  </blockquote>
  
  <p><code>call</code> gives the same thing.</p>
  
  <p>Calling it via <code>OdbcCommand</code> works fine with <code>call</code>:</p>
  
  <pre class="lang-cs prettyprint-override"><code>var input = 789;
  var sql = "call TP.MY_STORED_PROC (?, ?);";
  
  using (var tx = new TransactionScope(TransactionScopeOption.Suppress))
  using (var connection = new OdbcConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString))
  using (var command = new OdbcCommand(sql, connection))
  {
      command.Parameters.Add("@input_param", OdbcType.Int, 32).Value = input;
      command.Parameters.Add("@output_param", OdbcType.Int, 32).Direction = System.Data.ParameterDirection.Output;
      connection.Open();
      command.ExecuteNonQuery();
  
      object output = command.Parameters["@output_param"].Value;
      if (output is DBNull)
          return null;
  
      int output = Convert.ToInt32(output);
      return output;
  }
  </code></pre>
  
  <p>How can I call this thing and get a meaningful result in the output parameter, which I then stuff in a result set and echo to the screen?</p>