RE: Error: "remote query result rowtype does not match the specified FROM clause rowtype," on remote function call

From: Antonio Gomez <AGomez(at)EBSCO(dot)COM>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: RE: Error: "remote query result rowtype does not match the specified FROM clause rowtype," on remote function call
Date: 2019-03-25 22:20:03
Message-ID: BN7PR01MB36519470A5497618755DB544D65E0@BN7PR01MB3651.prod.exchangelabs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I figured it out, you have to specify the type twice, once inside the remote call and once outside.

Like this:

SELECT * FROM dblink('conn_str', 'select public._test1() as x(a int ,b int)') as x(a int ,b int);

Not optimal and not readily discernible, but there it is.

Thanks for your response!

--T.

-----Original Message-----
From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Sent: Monday, March 25, 2019 6:14 PM
To: Antonio Gomez <AGomez(at)EBSCO(dot)COM>; pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Error: "remote query result rowtype does not match the specified FROM clause rowtype," on remote function call

CAUTION: External E-mail

On 3/25/19 1:08 PM, Antonio Gomez wrote:
> This is my *remote* function:
>
> CREATEORREPLACE FUNCTIONpublic._test1()
>
> RETURNS record
>
> LANGUAGE plpgsql
>
> AS$function$
>
> DECLARE
>
> rec record;
>
> BEGIN
>
> select1,2intorec;
>
> returnrec;
>
> END$function$;
>
> This is my *local* function call:
>
> SELECTx.a, x.b
>
> FROMdblink('conn_str', 'select public._test1();')
>
> asx(a int ,b int);

Do not have time to spin a test up at the moment, but what happens if you do?"

SELECT *

FROM dblink('conn_str', 'select public._test1();')

as x(a int ,b int);

>
> This is the error thrown:
>
> ERROR: remote query result rowtype does notmatchthe specified
> FROMclause rowtype
>
> Question:
>
> Since DBLINK requires that I define a schema to place the function's
> return items, how do I make the call to recognize a record type being
> returned by the function.
>
> Thanks!
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2019-03-25 22:26:08 Re: Error: "remote query result rowtype does not match the specified FROM clause rowtype," on remote function call
Previous Message Adrian Klaver 2019-03-25 22:13:56 Re: Error: "remote query result rowtype does not match the specified FROM clause rowtype," on remote function call