Call Postgres function from Linked Server

This is a multi-part message in MIME format.

------_=_NextPart_001_01C8A09A.77823CF4
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Not to be repetitive but I think my approach on this has changed from
yesterday.



Using the Postgres ODBC driver (psqlodbc_08_03_0100) on windows, how do
I pass the command to execute a Function on another machine?



I am currently trying to execute the Function directly from SQL Server
Query Manager like this "EXEC [PostgreSQL].dta.testuser.mssql_test" but
get an error stating:



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'.



After corresponding with Hiroshi yesterday I now understand that the
error is due to SQL Server trying to interpret the function call before
it is handed off to ODBC, resulting in the error.



As a potential fix I thought using OPENQUERY might work but I don't know
the equivalent syntax to "EXEC [PostgreSQL].dta.testuser.mssql_test" to
use to call a Function using OPENQUERY.



Any help anyone can provide would be appreciated.



Thanks,



JeffCrumble




------_=_NextPart_001_01C8A09A.77823CF4
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:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
[at] font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
[at] font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
[at] font-face
{font-family:"Brush Script MT";
panose-1:3 6 8 2 4 4 6 7 3 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:export-only;}
[at] page 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>Not to be repetitive but I think my approach on =
this has
changed from yesterday.<o:p></o:p></p>

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

<p class=3DMsoNormal>Using the Postgres<span =
style=3D'font-family:"Arial","sans-serif"'>
</span>ODBC driver (psqlodbc_08_03_0100) on windows, how do I pass the =
command
to execute a Function on another machine?  <o:p></o:p></p>

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

<p class=3DMsoNormal>I am currently trying to execute the Function =
directly from
SQL Server Query Manager like this “EXEC
[PostgreSQL].dta.testuser.mssql_test” but get an error =
stating:<o:p></o:p></p>

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

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

<p class=3DMsoNormal>Error while executing the =
query".<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> </o:p></p>

<p class=3DMsoNormal>After corresponding with Hiroshi yesterday I now =
understand
that the error is due to SQL Server trying to interpret the function =
call
before it is handed off to ODBC, resulting in the error.<o:p></o:p></p>

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

<p class=3DMsoNormal>As a potential fix I thought using OPENQUERY might =
work but I
don’t know the equivalent syntax to “EXEC
[PostgreSQL].dta.testuser.mssql_test” to use to call a Function =
using
OPENQUERY.<o:p></o:p></p>

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

<p class=3DMsoNormal>Any help anyone can provide would be =
appreciated.<o:p></o:p></p>

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

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

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

<p class=3DMsoNormal><span style=3D'font-size:14.0pt;font-family:"Brush =
Script MT"'>JeffCrumble</span><o:p></o:p></p>

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

</div>

</body>

</html>

------_=_NextPart_001_01C8A09A.77823CF4--
Jeff Crumbley [ Do, 17 April 2008 16:51 ] [ ID #1944472 ]
Datenbanken » gmane.comp.db.postgresql.odbc » Call Postgres function from Linked Server

Vorheriges Thema: 32-bit ODBC Linked Server from 64 bit SQL Server
Nächstes Thema: Linked Server Error