title: Delphi XE: TSQLQuery raises "Input parameter mismatch"
body: <p>I've created a stored procedure (<code>SP_TEST</code>) in Firebird 2.5 that returns a selection and uses 3 input parameters.
  This <code>SP_TEST</code> works fine in IBExpress, when I enter e.g. the SQL command: <code>select * from SP_TEST(1,2,3)</code> there's a correct result.</p>
  
  <p>However, when I use the dbExpress components in Delphi XE to do the same selection, the message "Input parameter mismatch" is raised.
  I'm using the TSQLQuery component, with the CommandText property set to <code>"select * from SP_TEST(1,2,3)"</code>.
  When I define the same query in the CommandText property as I've defined in <code>SP_TEST</code>, I have a nice result.
  But including the stored procedure name in the select statement (with the right number of parameter) raises this error message.</p>
  
  <p>Can anyone please tell me what I'm doing wrong?</p>
  
  <p><strong>UPDATE - moved from pseudo-answer</strong> and formatting added: <a href="https://stackoverflow.com/editing-help">https://stackoverflow.com/editing-help</a></p>
  
  <pre><code>SET TERM ^ ;
  ALTER PROCEDURE SP_TEST (
      NJAAR Integer,
      NMAAND Integer,
      CREKNR Varchar(6) )
  RETURNS (
      TOTAAL Numeric(15,2),
      CODE Varchar(4),
      OMSCHR Varchar(40),
      RICHTING Varchar(3),
      PROG Numeric(18,2),
      TRANS Numeric(18,2) )
  AS
  BEGIN
    FOR
      SELECT a.CODE, a.OMSCHR, a.RICHTING,
      SUM(iif(richting='AF',-1,1) * COALESCE(p.bedrag,0)) as prog,
      SUM(iif(richting='AF',-1,1) * COALESCE(t.bedrag,0)) as trans,
      0 as totaal
      FROM POSTEN a
      left JOIN prognose p on p.POST = a.CODE and p.JAAR = :nJAAR and p.MAAND = :nMAAND
      left JOIN TRANSACT t on t.POST = a.CODE and EXTRACT(YEAR FROM t.datum) = :nJAAR and EXTRACT(MONTH FROM t.datum) = :nMAAND
      WHERE REKTOEPAS containing :cREKNR
      GROUP by a.CODE, a.OMSCHR, a.RICHTING
      INTO :CODE,
           :OMSCHR,
           :RICHTING,
           :PROG,
           :TRANS,
           :TOTAAL
    DO
    BEGIN
      totaal = iif(abs(prog) &gt; abs(trans),prog,trans);
      SUSPEND;
    END
  END^
  SET TERM ; ^
  </code></pre>
  
  <p>Entering the statement in IBExpert:</p>
  
  <pre><code>SELECT * FROM SP_TEST(2014,1,'0001')
  </code></pre>
  
  <p>returns a result set of several rows.</p>
  
  <p>When I pass the same query to <code>TSQLQuery.CommandText</code> (or to the <code>SQL</code> property, I also tried this), the message "Input parameter mismatch" is raised.</p>
  
  <p>I tried <code>TSQLStoredProc</code>, but then there's a message "Cursor not returned from Query" when I use the Open method.</p>
  
  <p>In fact, my stored procedure is kind of a view, and I like the result in my dbExpress components (<code>TSQLQuery</code> or <code>TSQLStoredProc</code>).
  As said, when I put the complete SQL code between "SELECT..." and the "GROUP BY" in the <code>TSQLQuery.SQL</code> propery, I get the resulting rows.  Using the stored procedure fails until now.</p>