Thread: PL/pgSQL function to run DDL on a remote server/cluster?

PL/pgSQL function to run DDL on a remote server/cluster?

From
Sbob
Date:
All;


Is it possible to execute DDL on a remote server/cluster from a PL/pgSQL 
function?
If so can someone point me to docs or an example?


Thanks in advance





Re: PL/pgSQL function to run DDL on a remote server/cluster?

From
Laurenz Albe
Date:
On Thu, 2023-03-23 at 12:03 -0600, Sbob wrote:
> Is it possible to execute DDL on a remote server/cluster from a PL/pgSQL
> function?
> If so can someone point me to docs or an example?

You cannot do that with the built-in tools.
You'd have to write an extension that can do that.

Yours,
Laurenz Albe



Re: PL/pgSQL function to run DDL on a remote server/cluster?

From
Tom Lane
Date:
Laurenz Albe <laurenz.albe@cybertec.at> writes:
> On Thu, 2023-03-23 at 12:03 -0600, Sbob wrote:
>> Is it possible to execute DDL on a remote server/cluster from a PL/pgSQL 
>> function?
>> If so can someone point me to docs or an example?

> You cannot do that with the built-in tools.
> You'd have to write an extension that can do that.

You do need an extension, but contrib/dblink should do fine.

            regards, tom lane



Re: PL/pgSQL function to run DDL on a remote server/cluster?

From
Laurenz Albe
Date:
On Thu, 2023-03-23 at 15:15 -0400, Tom Lane wrote:
> Laurenz Albe <laurenz.albe@cybertec.at> writes:
> > On Thu, 2023-03-23 at 12:03 -0600, Sbob wrote:
> > > Is it possible to execute DDL on a remote server/cluster from a PL/pgSQL
> > > function?
> > > If so can someone point me to docs or an example?
>
> > You cannot do that with the built-in tools.
> > You'd have to write an extension that can do that.
>
> You do need an extension, but contrib/dblink should do fine.

Ah, of course.  Silly of me.

Yours,
Laurenz Albe



Re: PL/pgSQL function to run DDL on a remote server/cluster?

From
Sbob
Date:
On 3/23/23 14:16, Laurenz Albe wrote:
> On Thu, 2023-03-23 at 15:15 -0400, Tom Lane wrote:
>> Laurenz Albe <laurenz.albe@cybertec.at> writes:
>>> On Thu, 2023-03-23 at 12:03 -0600, Sbob wrote:
>>>> Is it possible to execute DDL on a remote server/cluster from a PL/pgSQL
>>>> function?
>>>> If so can someone point me to docs or an example?
>>> You cannot do that with the built-in tools.
>>> You'd have to write an extension that can do that.
>> You do need an extension, but contrib/dblink should do fine.
> Ah, of course.  Silly of me.
>
> Yours,
> Laurenz Albe


Thanks Tom!