cannot call firebird stored procedure from php
<p>I have a firebird stored procedure sp_clinic_id that returns a string. It compiles and executes fine. The Sp has a suspend in its body.</p>

<p>So I used <code>select out1 from sp_clinic_id()</code> to call the procedure from php pdo.</p>

<p>Here's the code:</p>

<pre><code>$sqlproc = "select out1 from SP_CLINIC_ID()";

// execute the stored procedure
$stmt = $pdo-&gt;prepare($sqlproc);
$stmt-&gt;execute();
</code></pre>

<p>Instead of returning a prepared statement, pdo->prepare is returning false. </p>

<p>The error is "Dynamic Sql Error -104. Token Unknown". Since the procedure compiles and executes fine in firebird, I cannot understand why I'm getting a Dynamic Sql error. </p>

<p>Here is the stored procedure definition:</p>

<pre><code>CREATE PROCEDURE SP_CLINIC_ID
RETURNS(
  MAXID VARCHAR(10))
AS
DECLARE VARIABLE temp_char CHAR(10);
DECLARE VARIABLE temp_id INTEGER;
BEGIN
  /* Procedure body */

  select MAX(CLINIC_id) from COVER_SHEET into MAXID;

  select SUBSTRING(:MAXID from 4 for CHAR_LENGTH(:MAXID)) 
  from rdb$database into temp_char ;

  select cast(:temp_char as NUMERIC) from rdb$database into temp_id;

  temp_id = temp_id + 1;

   if ( temp_id &lt; 10) THEN
  BEGIN
    maxid = 'REG000000'|| temp_id;
  END

  else if ( temp_id &lt; 100) THEN
  begin
  maxid = 'REG00000'|| temp_id;
  end  


  else if ( temp_id &lt; 1000) THEN
  begin
  maxid = 'REG0000'|| temp_id;
  end  

  else if ( temp_id &lt; 10000) THEN
  begin
  maxid = 'REG000'|| temp_id;
  end  

  ELSE if ( temp_id &lt; 100000 ) THEN
  begin
  maxid = 'REG00'|| temp_id;
  end  

  ELSE if ( temp_id &lt; 1000000) THEN
  begin
  maxid = 'REG0'|| temp_id;
  end  

  ELSE if ( temp_id &lt; 10000000) THEN
  begin
  maxid = 'REG'|| temp_id;
  end  

  SUSPEND;
END;
</code></pre>