Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Interfaces Odbc > Linked Server E...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 2343 of 2403
Post > Topic >>

Linked Server Error

by jeffc@[EMAIL PROTECTED] ("Jeff Crumbley") Apr 16, 2008 at 04:09 PM

This is a multi-part message in MIME format.

------_=_NextPart_001_01C8A006.2986C0E6
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

To whom it may concern:

=20

I am running SQL Server on Windows 2003 R2 (32-bit) connecting to
Postgres on SCO Unix.  I have installed the ODBC driver
(psqlodbc_08_03_0100) and can query the tables in Postgres using
OPENQUERY from SQL Server.  Everything works great where this is
concerned.

=20

The issue I am having involves calling a Postgres Function from SQL
Server.  The user ID that I am using to connect to Postgres is a
SuperUser and the function I created in Postgres is accepted without a
error (in pgAdmin III). =20

=20

The Function:

-------------------------------------------------------

CREATE OR REPLACE FUNCTION mssql_test()

  RETURNS integer AS

$BODY$DECLARE

                retval bigint;

BEGIN

                retval:=3D(SELECT count(*) FROM dminvoice);

                return retval;

END;$BODY$

  LANGUAGE 'plpgsql' VOLATILE;

ALTER FUNCTION mssql_test() OWNER TO testuser;

GRANT EXECUTE ON FUNCTION mssql_test() TO public;

GRANT EXECUTE ON FUNCTION mssql_test() TO testuser;

=20

The way I am calling the function is as follows:

=20

Function Call:

-------------------------------------------------------

EXEC [PostgreSQL].dta.testuser.mssql_test   (ODBC
Connection.Database.User.Function Name)

=20

The response I get from Postgres is:

=20

Error:

-------------------------------------------------------

OLE DB provider "MSDASQL" for linked server "PostgreSQL" returned
message "ERROR: syntax error at or near "1";

Error while executing the query".

Msg 7212, Level 17, State 1, Line 1

Could not execute procedure 'mssql_test' on remote server 'PostgreSQL'.

=20

Any help you can provide on this would be greatly appreciated.

=20

Thanks in advance,

=20

Jeff


------_=_NextPart_001_01C8A006.2986C0E6
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:x=3D"urn:schemas-microsoft-com:office:excel" =
xmlns:p=3D"urn:schemas-microsoft-com:office:powerpoint" =
xmlns:a=3D"urn:schemas-microsoft-com:office:access" =
xmlns:dt=3D"uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" =
xmlns:s=3D"uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" =
xmlns:rs=3D"urn:schemas-microsoft-com:rowset" xmlns:z=3D"#RowsetSchema" =
xmlns:b=3D"urn:schemas-microsoft-com:office:publisher" =
xmlns:ss=3D"urn:schemas-microsoft-com:office:spreadsheet" =
xmlns:c=3D"urn:schemas-microsoft-com:office:component:spreadsheet" =
xmlns:oa=3D"urn:schemas-microsoft-com:office:activation" =
xmlns:html=3D"http://www.w3.org/TR/REC-html40"
=
xmlns:q=3D"http://schemas.xmlsoap.org/soap/envelope/"
xmlns:D=3D"DAV:" =
xmlns:x2=3D"http://schemas.microsoft.com/office/excel/2003/xml"
=
xmlns:ois=3D"http://schemas.microsoft.com/sharepoint/soap/ois/"
=
xmlns:dir=3D"http://schemas.microsoft.com/sharepoint/soap/directory/"
=
xmlns:ds=3D"http://www.w3.org/2000/09/xmldsig#"
=
xmlns:dsp=3D"http://schemas.microsoft.com/sharepoint/dsp"
=
xmlns:udc=3D"http://schemas.microsoft.com/data/udc"
=
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema"
=
xmlns:sub=3D"http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/"=
 xmlns:ec=3D"http://www.w3.org/2001/04/xmlenc#"
=
xmlns:sp=3D"http://schemas.microsoft.com/sharepoint/"
=
xmlns:sps=3D"http://schemas.microsoft.com/sharepoint/soap/"
=
xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"
=
xmlns:udcxf=3D"http://schemas.microsoft.com/data/udc/xmlfile"
=
xmlns:wf=3D"http://schemas.microsoft.com/sharepoint/soap/workflow/"
=
xmlns:mver=3D"http://schemas.openxmlformats.org/markup-compatibility/2006=
" xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml"
=
xmlns:mrels=3D"http://schemas.openxmlformats.org/package/2006/relation****=
ps" =
xmlns:ex12t=3D"http://schemas.microsoft.com/exchange/services/2006/types"=
 =
xmlns:ex12m=3D"http://schemas.microsoft.com/exchange/services/2006/messag=
es" xmlns=3D"http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @[EMAIL PROTECTED]
"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@[EMAIL PROTECTED]
 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
..MsoChpDefault
	{mso-style-type:ex****t-only;}
@[EMAIL PROTECTED]
 Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
	{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext=3D"edit">
  <o:idmap v:ext=3D"edit" data=3D"1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=3DEN-US link=3Dblue vlink=3Dpurple>

<div class=3DSection1>

<p class=3DMsoNormal>To whom it may concern:<o:p></o:p></p>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal>I am running SQL Server on Windows 2003 R2 (32-bit)
connecting to Postgres on SCO Unix.&nbsp; I have installed the ODBC =
driver (psqlodbc_08_03_0100)
and can query the tables in Postgres using OPENQUERY from SQL =
Server.&nbsp;
Everything works great where this is concerned.<o:p></o:p></p>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal>The issue I am having involves calling a Postgres =
Function
from SQL Server.&nbsp; The user ID that I am using to connect to =
Postgres is a SuperUser
and the function I created in Postgres is accepted without a error (in =
pgAdmin III).&nbsp;
<o:p></o:p></p>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal>The Function:<o:p></o:p></p>

<p =
class=3DMsoNormal>-------------------------------------------------------=
<o:p></o:p></p>

<p class=3DMsoNormal>CREATE OR REPLACE FUNCTION =
mssql_test()<o:p></o:p></p>

<p class=3DMsoNormal>&nbsp; RETURNS integer AS<o:p></o:p></p>

<p class=3DMsoNormal>$BODY$DECLARE<o:p></o:p></p>

<p =
class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; retval
bigint;<o:p></o:p></p>

<p class=3DMsoNormal>BEGIN<o:p></o:p></p>

<p =
class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; retval:=3D(SELECT
count(*) FROM dminvoice);<o:p></o:p></p>

<p =
class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return
retval;<o:p></o:p></p>

<p class=3DMsoNormal>END;$BODY$<o:p></o:p></p>

<p class=3DMsoNormal>&nbsp; LANGUAGE 'plpgsql' VOLATILE;<o:p></o:p></p>

<p class=3DMsoNormal>ALTER FUNCTION mssql_test() OWNER TO =
testuser;<o:p></o:p></p>

<p class=3DMsoNormal>GRANT EXECUTE ON FUNCTION mssql_test() TO =
public;<o:p></o:p></p>

<p class=3DMsoNormal>GRANT EXECUTE ON FUNCTION mssql_test() TO =
testuser;<o:p></o:p></p>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal>The way I am calling the function is as =
follows:<o:p></o:p></p>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal>Function Call:<o:p></o:p></p>

<p =
class=3DMsoNormal>-------------------------------------------------------=
<o:p></o:p></p>

<p class=3DMsoNormal>EXEC [PostgreSQL].dta.testuser.mssql_test =
&nbsp;&nbsp;(ODBC
Connection.Database.User.Function Name)<o:p></o:p></p>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal>The response I get from Postgres is:<o:p></o:p></p>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal>Error:<o:p></o:p></p>

<p =
class=3DMsoNormal>-------------------------------------------------------=
<o:p></o:p></p>

<p class=3DMsoNormal>OLE DB provider &quot;MSDASQL&quot; for linked =
server
&quot;PostgreSQL&quot; returned message &quot;ERROR: syntax error at or =
near
&quot;1&quot;;<o:p></o:p></p>

<p class=3DMsoNormal>Error while executing the =
query&quot;.<o:p></o:p></p>

<p class=3DMsoNormal>Msg 7212, Level 17, State 1, Line 1<o:p></o:p></p>

<p class=3DMsoNormal>Could not execute procedure 'mssql_test' on remote =
server
'PostgreSQL'.<o:p></o:p></p>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal>Any help you can provide on this would be greatly
appreciated.<o:p></o:p></p>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal>Thanks in advance,<o:p></o:p></p>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal>Jeff<o:p></o:p></p>

</div>

</body>

</html>

------_=_NextPart_001_01C8A006.2986C0E6--
 




 2 Posts in Topic:
Linked Server Error
jeffc@[EMAIL PROTECTED]   2008-04-16 16:09:30 
Re: Linked Server Error
z-saito@[EMAIL PROTECTED]  2008-04-17 06:58:04 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Sep 7 6:48:07 CDT 2008.