agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: ml@ft-c.de
To: pgsql-sql@lists.postgresql.org
Subject: dblink_exists
Date: Mon, 21 Dec 2020 02:35:32 +0100
Message-ID: <ad1e2ca9dbbacae8ca129ed2a7c1cde975c0ed18.camel@ft-c.de> (raw)

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







view thread (3+ messages)  latest in thread

Message-ID: <ad1e2ca9dbbacae8ca129ed2a7c1cde975c0ed18.camel@ft-c.de>
Permalink:  ../ad1e2ca9dbbacae8ca129ed2a7c1cde975c0ed18.camel@ft-c.de/
Also on:    postgresql.org/message-id/ad1e2ca9dbbacae8ca129ed2a7c1cde975c0ed18.camel@ft-c.de

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ml@ft-c.de, pgsql-sql@lists.postgresql.org
  Subject: Re: dblink_exists
  In-Reply-To: <ad1e2ca9dbbacae8ca129ed2a7c1cde975c0ed18.camel@ft-c.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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