Linked Server Error

Linked Server Error

am 16.04.2008 23:09:30 von Jeff Crumbley

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

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:spread sheet" =
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/x ml" =
xmlns:ois=3D"http://schemas.microsoft.com/sharepoint/soap/oi s/" =
xmlns:dir=3D"http://schemas.microsoft.com/sharepoint/soap/di rectory/" =
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/20 02/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/wor kflow/" =
xmlns:mver=3D"http://schemas.openxmlformats.org/markup-compa tibility/2006=
" xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns:mrels=3D"http://schemas.openxmlformats.org/package/200 6/relationshi=
ps" =
xmlns:ex12t=3D"http://schemas.microsoft.com/exchange/service s/2006/types"=
=
xmlns:ex12m=3D"http://schemas.microsoft.com/exchange/service s/2006/messag=
es" xmlns=3D"http://www.w3.org/TR/REC-html40">


charset=3Dus-ascii">









To whom it may concern:



 



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.



 



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



 



The Function:



class=3DMsoNormal>------------------------------------------ -------------=



CREATE OR REPLACE FUNCTION =
mssql_test()



  RETURNS integer AS



$BODY$DECLARE



class=3DMsoNormal>         &=
nbsp;      retval
bigint;



BEGIN



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



class=3DMsoNormal>         &=
nbsp;      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;



 



The way I am calling the function is as =
follows:



 



Function Call:



class=3DMsoNormal>------------------------------------------ -------------=



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



 



The response I get from Postgres is:



 



Error:



class=3DMsoNormal>------------------------------------------ -------------=



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



 



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



 



Thanks in advance,



 



Jeff









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

Re: Linked Server Error

am 16.04.2008 23:58:04 von Hiroshi Saito

Hi.

In it, "AS" key word was an indispensable reason and a problem. However, it becomes possible because it was equipped from version8.4 of server.
See,
http://winpg.jp/~saito/psqlODBC/SQLServer_linkserver_Postgre SQL2.png

Regards,
Hiroshi Saito

"Jeff Crumbley"
>To whom it may concern:
>
>
>
>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.
>
>
>
>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).
>
>
>
>The Function:
>
>-------------------------------------------------------
>
>CREATE OR REPLACE FUNCTION mssql_test()
>
> RETURNS integer AS
>
>$BODY$DECLARE
>
> retval bigint;
>
>BEGIN
>
> retval:=(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;
>
>
>
>The way I am calling the function is as follows:
>
>
>
>Function Call:
>
>-------------------------------------------------------
>
>EXEC [PostgreSQL].dta.testuser.mssql_test (ODBC
>Connection.Database.User.Function Name)
>
>
>
>The response I get from Postgres is:
>
>
>
>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'.
>
>
>
>Any help you can provide on this would be greatly appreciated.
>
>
>
>Thanks in advance,
>
>
>
>Jeff
>


--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc