agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
dblink_exists
3+ messages / 2 participants
[nested] [flat]

* dblink_exists
@ 2020-12-21 01:35  ml@ft-c.de
  0 siblings, 1 reply; 3+ messages in thread

From: ml@ft-c.de @ 2020-12-21 01:35 UTC (permalink / raw)
  To: pgsql-sql@lists.postgresql.org

Hello,

I need a function like "dblink_exists()", but there is no one.
Here is my script:

create function trading.stats_symbols()  returns boolean as  
$$
declare
sql text;
begin 
sql='...';
truncate trading.stats_symbols ; 
perform dblink_connect('updatesymbols', 'dbname=ftc') ;
perform dblink_send_query('updatesymbols', sql) ;
perform dblink_disconnect('updatesymbols') ;
end;
$$ language plpgsql;

My general problem:
I need a command that send a answer immediately and not, when the query
if finished.  
dblink_send_query connect with the own database and runs a long time. 

When someone start the script again (when it is running), so I need a
section like:

if dblink_exists(updatesymbols)   -- but this function do not exists
then 
return false -- or do nothing
end if;

dblink_is_busy is not usable: when the function is not running, it
stops. 


2. question:
When dlink_send_query is running, 
select dblink_get_connections() 
send NULL as answer. 


Franz







^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: dblink_exists
@ 2020-12-21 01:52  David G. Johnston <david.g.johnston@gmail.com>
  parent: ml@ft-c.de
  0 siblings, 1 reply; 3+ messages in thread

From: David G. Johnston @ 2020-12-21 01:52 UTC (permalink / raw)
  To: ml@ft-c.de <ml@ft-c.de>; +Cc: pgsql-sql@lists.postgresql.org <pgsql-sql@lists.postgresql.org>

On Sunday, December 20, 2020, <ml@ft-c.de> wrote:

>
> My general problem:
> I need a command that send a answer immediately and not, when the query
> if finished.


>
dblink_exec()?



>
> When someone start the script again (when it is running), so I need a
> section like:


Advisory locks?


>
> 2. question:
> When dlink_send_query is running,
> select dblink_get_connections()
> send NULL as answer.
>
>
Don’t know - though suggest showing actual code that results in this
behavior.

David J.

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: dblink_exists
@ 2020-12-21 05:07  ml@ft-c.de
  parent: David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: ml@ft-c.de @ 2020-12-21 05:07 UTC (permalink / raw)
  To: pgsql-sql@lists.postgresql.org

On Sun, 2020-12-20 at 18:52 -0700, David G. Johnston wrote:
> On Sunday, December 20, 2020, <ml@ft-c.de> wrote:
> > 
> > My general problem:
> > I need a command that send a answer immediately and not, when the
> > query
> > if finished. 
> dblink_exec()?
  no, it needs a connection string
>  
> > 
> > When someone start the script again (when it is running), so I need
> > a
> > section like:
> Advisory locks?
lock on a table: it is the  best solution  
> > 
> > 2. question:
> > When dlink_send_query is running, 
> > select dblink_get_connections() 
> > send NULL as answer. 
> > 
> Don’t know - though suggest showing actual code that results in this
> behavior.

Franz

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2020-12-21 05:07 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-12-21 01:35 dblink_exists ml@ft-c.de
2020-12-21 01:52 ` David G. Johnston <david.g.johnston@gmail.com>
2020-12-21 05:07   ` ml@ft-c.de

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox