Re: mssql_execute(): stored procedure execution failed

Sylvain Viart - Gmail <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
Hi Robert,

On 28/05/2010 17:44, Robert Gonzalez wrote:
> The fix is to free your result resources before sending another init request
> to the server. I think you are running into something that has been causing
> issues for a while, most recently in PDO as an unbuffered query error. What
> is happening is the server is sending back a result but the response is
> being held open on it until the next direct query is sent. But since you are
> not sending a query and rather sending an init call the server is choking on
> the request.
>
> After every one of your queries and subsequent result reads, try adding in a
> call to mssql_free_result($yourResultVar). That should make your problem go
> away. At least it did for me in my testing just now
Yes, may be.
I'm gonna try that.

One try we made, which totaly crash the lib (may be somewhere in apache 
+ persistent connection  + freetds)

Was to replace the most failing mssql_init() call with a function wrapper :

here's the wrapper code

//  $rt = call_proc("linsyn_mail_exclusion_get",
//      "@id", $in,
//      "@type", $tag_mail
//  );
function call_proc($procname)
{
     global $conn;
     $sql = "EXEC $procname ";

     // lecture des paramètres en paire
     $n = func_num_args();
     for($i = 1;$i < $n; $i += 2)
     {
         $param = func_get_arg($i);
         $var = func_get_arg($i + 1);

         // composition
         $sql .= "$param = ";

         if(is_int($var))
         {
             $sql .= $var;
         }
         else
         {
             $sql .= "'$var'";
         }

         if($i < $n - 2)
             $sql .= ', ';
     }

     my_log("call_proc($sql)");
     return mssql_query($sql, $conn);
}


This code (legacy):
$ps = mssql_init("linsyn_priv_get");
$result = mssql_execute($ps);
mssql_free_statement($ps);


became:

$result = call_proc("linsyn_priv_get");

It makes all mssql_init() failing, on all query and all pages on the web 
site, nothing works anymore.
I've to revert the code and restart apache to get it back.

hum...
If only I was able to get a valuable error log...

Regards,
Sylvain.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.