Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C6223476583 for ; Mon, 16 Sep 2002 13:12:29 -0400 (EDT) Received: from hotmail.com (dav23.law15.hotmail.com [64.4.22.80]) by postgresql.org (Postfix) with ESMTP id 8753A4764BE for ; Mon, 16 Sep 2002 13:12:24 -0400 (EDT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Mon, 16 Sep 2002 10:12:24 -0700 X-Originating-IP: [204.244.28.188] From: "david williams" To: Subject: Re: Problem returning a cursor through ODBC to ASP layer from postgres Date: Mon, 16 Sep 2002 13:14:57 -0400 MIME-Version: 1.0 X-Mailer: MSN Explorer 7.00.0021.1900 Content-Type: multipart/alternative; boundary="----=_NextPart_001_0000_01C25D83.0DBB1AA0" Message-ID: X-OriginalArrivalTime: 16 Sep 2002 17:12:24.0263 (UTC) FILETIME=[39A06D70:01C25DA4] X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/66 X-Sequence-Number: 2037 ------=_NextPart_001_0000_01C25D83.0DBB1AA0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable The entire ASP page (read.asp) is here: read.asp <%=20=20 strconn=3D"DSN=3Dp_cars4u;uid=3Dpostgres;pwd=3D" 'mySQL=3D"select * from users" mySQL =3D "begin; "&vbcrlf mySQL =3D mySQL & "select getallusers('rs'); " mySQL =3D mySQL & "fetch all in rs; " 'mySQL =3D mySQL & "commit; " 'call query2table(mySQL,strconn)' %> <%=20=20 sub query2table(inputquery, inputDSN) dim conntemp, rstemp set conntemp=3Dserver.createobject("adodb.connection") conntemp.open inputDSN set rstemp=3Dconntemp.execute(inputquery) howmanyfields=3Drstemp.fields.count -1%> <% 'Put Headings On The Table of Field Names for i=3D0 to howmanyfields %> <% next %> <% ' Now lets grab all the records do while not rstemp.eof %> <------------------ LINE= 35 <% for i =3D 0 to howmanyfields thisvalue=3Drstemp(i) If isnull(thisvalue) then thisvalue=3D" " end if%> <% next %> <%rstemp.movenext loop%>
<%=3Drstemp(i).name%>
<%=3Dthisvalue%>
<% rstemp.close set rstemp=3Dnothing conntemp.close set conntemp=3Dnothing end sub%> I get this error: Error Type: ADODB.Recordset (0x800A0E78) Operation is not allowed when the object is closed. /read.asp, line 35 It seems that the object is closed already because it returns nothing. Thanks=20=20 Dave ----- Original Message ----- From: Janet Borschowa Sent: Monday, September 16, 2002 1:05 PM To: 'david williams'; pgsql-odbc@postgresql.org Subject: RE: [ODBC] Problem returning a cursor through ODBC to ASP layer fr= om postgres I believe that when you call commit the refcursor is closed. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20= =20 Janet Borschowa=20=20 Software Engineer, Database Products=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 Rogue Wave Software=20=20 (541) 753-1931 FAX: (541) 757-4630=20=20 mailto:borschow@roguewave.com http://www.roguewave.com =20=20=20 -----Original Message----- From: david williams [mailto:dw_remote@hotmail.com] Sent: Friday, September 13, 2002 9:29 AM To: pgsql-odbc@postgresql.org Subject: [ODBC] Problem returning a cursor through ODBC to ASP layer from postgres I have created a function in postgres called getallusers(var) that returns a cursor. This works fine at the psql level but when I try to return it through ODBC I get errors. The function is as follows: CREATE OR REPLACE FUNCTION getallusers(refcursor) RETURN refcursor AS' begin open $1 for select * from users; return $1; end; ' language 'plpgsql'; I call it like this: <%=20=20 strconn=3D"DSN=3Dp_test;uid=3Dpostgres;pwd=3D" mySQL =3D "begin "&vbcrlf mySQL =3D mySQL & "select getallusers('rs'); " mySQL =3D mySQL & "fetch all in rs; " mySQL =3D mySQL & "commit; " call query2table(mySQL,strconn) %> This does not seem to return anything. Thanks !-------------------------------------! David Williams _____=20=20=20 Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com Get more from the Web. FREE MSN Explorer downloa= d : http://explorer.msn.com ------=_NextPart_001_0000_01C25D83.0DBB1AA0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
The entire ASP p= age (read.asp) is here:
 

<HTML><HEA= D>
<TITLE>read.asp</TITLE>
<body bgcolor=3D"#FFFFFF= "></HEAD>
<%
strconn=3D"DSN=3Dp_cars4u;uid=3Dpostgres;pw= d=3D"
'mySQL=3D"select * from users"
mySQL =3D "begin; "&vbcrlfmySQL =3D mySQL & "select getallusers('rs'); "
mySQL =3D mySQL &am= p; "fetch all in rs; "
'mySQL =3D mySQL & "commit; "

'call qu= ery2table(mySQL,strconn)'
%>

</BODY>
</HTML>

<%
sub query2table(inputquery, inputDSN)
   dim co= nntemp, rstemp
   set conntemp=3Dserver.createobject("adodb.co= nnection")
   conntemp.open inputDSN
   set rstem= p=3Dconntemp.execute(inputquery)
   howmanyfields=3Drstemp.fie= lds.count -1%>
   <table border=3D1><tr>
&nb= sp;  <% 'Put Headings On The Table of Field Names
   f= or i=3D0 to howmanyfields %>
      &nbs= p;      <td><b><%=3Drstemp(i).name%= ></B></TD>
   <% next %>
   = </tr>
   <% ' Now lets grab all the records
 =   do while not rstemp.eof %>      &nb= sp;            =    <------------------ LINE 35
    &nbs= p; <tr>
      <% for i =3D 0 to howman= yfields
         thisvalue=3Drst= emp(i)
         If isnull(thisva= lue) then
          &n= bsp; thisvalue=3D"&nbsp;"
       =   end if%>
         = ;    <td valign=3Dtop><%=3Dthisvalue%></td>= ;
      <% next %>
   &= nbsp;  </tr>
      <%rstemp.moven= ext
   loop%>
   </table>
  = ; <%
   rstemp.close
   set rstemp=3Dnothing   conntemp.close
   set conntemp=3Dnothing
end= sub%>

I get this error:
 
Error Typ= e:
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the obj= ect is closed.
/read.asp, line 35
It seems that the objec= t is closed already because it returns nothing.
 
Thanks
 
Dave
----- Origina= l Message -----
From: Janet Borschowa
Sent: Monday, September 16, 2002 1:05 PM
To: 'david williams'; pgsql-odbc@postgresql.org
Subject: RE: [ODBC] Problem retur= ning a cursor through ODBC to ASP layer from postgres
 I believe that when you call commit the refcursor is closed.

=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
J= anet Borschowa
Software Engineer, Database Products   &n= bsp;            = ;       
Rogue Wave Software
(54= 1) 753-1931   FAX: (541) 757-4630
mailto:borschow@roguewave.c= om <mailto:borschow@roguewave.com>
http://www.roguewave.com <ht= tp://www.roguewave.com/> 



-----Original Message----= -
From: david williams [mailto:dw_remote@hotmail.com]
Sent: Friday, S= eptember 13, 2002 9:29 AM
To: pgsql-odbc@postgresql.org
Subject: [ODB= C] Problem returning a cursor through ODBC to ASP layer from
postgres

I have created a function in postgres called getallusers(var) that= returns a
cursor. This works fine at the psql level but when I try to r= eturn it
through ODBC I get errors.

The function is as follows:
CREATE OR REPLACE FUNCTION getallusers(refcursor) RETURN refcursor AS= '

begin
open $1 for select * from users;
return $1;
end;' language 'plpgsql';


I call it like this:

<%
str= conn=3D"DSN=3Dp_test;uid=3Dpostgres;pwd=3D"
mySQL =3D "begin "&vbcrl= f
mySQL =3D mySQL & "select getallusers('rs'); "
mySQL =3D mySQL = & "fetch all in rs; "
mySQL =3D mySQL & "commit; "
call query= 2table(mySQL,strconn)
%>


This does not seem to return anyt= hing.

Thanks


!-------------------------------------!
D= avid Williams


  _____ 

Get more from the Web. = FREE MSN Explorer download : http://explorer.msn.com
<http://explorer= .msn.com>


Get more fr= om the Web. FREE MSN Explorer download : http://explorer.msn.com

------=_NextPart_001_0000_01C25D83.0DBB1AA0--