<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">Hi Gauthier, that answer was perfect! I just tried it out and It completely solved my problem. Thanks so much! Grant.</span><br></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Oct 10, 2013 at 8:58 AM, Gauthier Segay <span dir="ltr">&lt;<a href="mailto:gauthier.segay@gmail.com" target="_blank">gauthier.segay@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hello Grant, pulling this topic out of the archive as I face similar issue and found a work around.<br><br>I&#39;m unsure what&#39;s happening in gp_somestoredproc but if using the sql management studio, you see some output such as<br>
<br>(X row(s) affected)<br><br>then you might want to put &quot;set nocount on&quot; before issuing the statement<br><br>I&#39;m unsure what&#39;s the status of multiple resultset in hdbc / hdbc-odbc but I did succeed pulling results out of first resultset of a stored procedure call<br>
<br>(sorry for html email, sending this from google groups)<div><div class="h5"><br><br>On Friday, 1 February 2013 01:16:38 UTC+1, grant  wrote:</div></div><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5">Hi,
<br>
<br>I am trying to call a stored procedure (exec gp_somestoredproc 123,22) 
<br>using microsoft sql server 2008 R2 using hdbc-odbc.
<br>  
<br>Here is the haskell code:
<br>
<br>import Database.HDBC 
<br>import Database.HDBC.ODBC
<br>import Control.Monad
<br>import Data.Maybe
<br>import qualified Data.ByteString.Char8 as B
<br>
<br>test1 = do 
<br>  c &lt;- connectODBC &quot;Driver={SQL Server};Server=?;Database=?;<u></u>uid=sa;pwd=?;&quot;
<br>  p &lt;- prepare c &quot;exec gp_somestoredproc 123,22&quot; -- returns no data
<br> --  p &lt;- prepare c &quot;exec [sys].sp_datatype_info_100 0,@ODBCVer=4;exec 
<br>gp_somestoredproc 123,22&quot; -- all is good
<br>  e &lt;- execute p []  -- returns 6 (number of rows)
<br>  putStrLn $ &quot;execute &quot; ++ show e
<br>  r &lt;- fetchAllRows&#39; p
<br>  putStrLn $ &quot;fetchAllRows&#39; &quot; ++ show r 
<br>
<br>
<br>The problem is that this code returns the number of rows correctly but 
<br>doesn&#39;t return data nor are there any errors.
<br>
<br>However, I ran a perl program using perl dbi and got the data correctly.
<br>
<br>Here is the perl code:
<br>
<br>#!/usr/bin/perl
<br>use DBI;
<br>
<br>  my $user = &#39;sa&#39;;
<br>  my $pw = &#39;????&#39;;
<br>  my $dsn = &#39;????&#39;;
<br>  my $dbh = DBI-&gt;connect(&quot;dbi:ODBC:$dsn&quot;, $user, $pw,
<br>       {PrintError =&gt; 1, RaiseError =&gt; 1});
<br>  if (!$dbh) {
<br>     print &quot;error: connection: $DBI::err\n$DBI::errstr\n$DBI:<u></u>:state\n&quot;;
<br>  }
<br>  my $type_info = $dbh-&gt;type_info(93);
<br>  while(my($key, $value) = each(%$type_info)){
<br>     print &quot;$key =&gt; $value\n&quot;;
<br>  };
<br>  my $sql = &quot;exec gp_somestoredproc 123,22&quot;;
<br>  my $sth = $dbh-&gt;prepare($sql);  
<br>  my $r   = $sth-&gt;execute;
<br>  while (my ($db) = $sth-&gt;fetchrow_array) {
<br>     print $db . &quot;\n===\n&quot;;
<br>
<br>  }
<br>  $dbh-&gt;disconnect if $dbh;
<br>
<br>I traced both versions and noticed that the perl dbi version first called 
<br>   
<br>   exec [sys].sp_datatype_info_100 0,@ODBCVer=4
<br>
<br>So I prefixed the stored proc call in haskell with &quot;exec 
<br>[sys].sp_datatype_info_100 0,@ODBCVer=4;&quot; and it worked fine.
<br>
<br>In short:
<br>
<br>FAILS  p &lt;- prepare c &quot;exec gp_somestoredproc 123,22&quot;  -- returns number of rows 
<br>but no data
<br>
<br>WORKS  p &lt;- prepare c &quot;exec [sys].sp_datatype_info_100 0,@ODBCVer=4;exec 
<br>gp_somestoredproc 123,22&quot; 
<br>
<br>I have no idea why this works. 
<br>
<br>sp_datatype_info_100 just dumps out the fields types ...
<br>
<br>More information:
<br>
<br>The stored procedure returns data with user defined field types.
<br>I have managed to do selects against tables with user defined field types 
<br>without any problems using hdbc-odbc.
<br>I couldn&#39;t emulate this error on a local older version of mssql server 
<br>(Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64)  express) but the perl dbi 
<br>prefixed the stored procedure call with  &quot;exec sp_datatype_info 0,@ODBCVer=3&quot;
<br>I am running this against Microsoft SQL Server 2008 R2 (RTM) - 10.50.1797.0 
<br>(X64)   
<br>
<br>I would appreciate any pointers you can give me.
<br>Thanks
<br>Grant
<br>
<br>
<br>
<br>______________________________<u></u>_________________
<br>Haskell-Cafe mailing list
<br></div></div><a>Haskel...@haskell.org</a>
<br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/<u></u>mailman/listinfo/haskell-cafe</a>
<br></blockquote></div><br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div>