pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedtime delay function
4+ messages / 4 participants
[nested] [flat]
* time delay function
@ 2003-07-22 07:59 Girish Bajaj <gbajaj@tietronix.com>
0 siblings, 1 reply; 4+ messages in thread
From: Girish Bajaj @ 2003-07-22 07:59 UTC (permalink / raw)
To: pgsql-sql
Pseudo code:
begin trans
select * from table1
WAIT FOR 20 SECS
update table1 set blah = 'blah'
end transcation
In pgplsql, Im looking for something like a function that I can use to make the process to wait for 20 secs before continuing to execute the next sql statment?
Thanks,
Girish
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: time delay function
@ 2003-07-22 08:22 Christoph Haller <ch@rodos.fzk.de>
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Haller @ 2003-07-22 08:22 UTC (permalink / raw)
To: pgsql-sql; gbajaj@tietronix.com
>
> Pseudo code:
>
> begin trans
> select * from table1
> WAIT FOR 20 SECS
> update table1 set blah = 'blah'
> end transcation
>
> In pgplsql, Im looking for something like a function that I can use to
make the process to wait for 20 secs before con
tinuing to execute the next sql statment?
>
AFAIK there is no such thing.
But probably you can write a C function,
which waits for N seconds and which can
be called by your plpgsql function.
Regards, Christoph
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: time delay function
@ 2003-07-22 09:34 Peter Eisentraut <peter_e@gmx.net>
parent: Girish Bajaj <gbajaj@tietronix.com>
0 siblings, 0 replies; 4+ messages in thread
From: Peter Eisentraut @ 2003-07-22 09:34 UTC (permalink / raw)
To: Girish Bajaj <gbajaj@tietronix.com>; +Cc: pgsql-sql
Girish Bajaj writes:
> In pgplsql, Im looking for something like a function that I can use to
> make the process to wait for 20 secs before continuing to execute the
> next sql statment?
There is no built-in support for that, but you could write your own
function in C that accomplishes that, for example by calling sleep().
--
Peter Eisentraut peter_e@gmx.net
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: time delay function
@ 2003-07-23 19:48 Robert Treat <xzilla@users.sourceforge.net>
parent: Christoph Haller <ch@rodos.fzk.de>
0 siblings, 0 replies; 4+ messages in thread
From: Robert Treat @ 2003-07-23 19:48 UTC (permalink / raw)
To: Christoph Haller <ch@rodos.fzk.de>; +Cc: pgsql-sql; gbajaj@tietronix.com
On Tue, 2003-07-22 at 04:22, Christoph Haller wrote:
> >
> > Pseudo code:
> >
> > begin trans
> > select * from table1
> > WAIT FOR 20 SECS
> > update table1 set blah = 'blah'
> > end transcation
> >
> > In pgplsql, Im looking for something like a function that I can use to
> make the process to wait for 20 secs before con
> tinuing to execute the next sql statment?
> >
> AFAIK there is no such thing.
> But probably you can write a C function,
> which waits for N seconds and which can
> be called by your plpgsql function.
> Regards, Christoph
>
seems like this would work:
21343=# create or replace function wait(integer) returns bool as '
21343'# declare
21343'# ahora timestamptz;
21343'# delay alias for $1;
21343'# go timestamptz;
21343'# begin
21343'# select now() + (delay || ''seconds'')::interval into go;
21343'#
21343'# loop
21343'# select timeofday() into ahora;
21343'# exit when ahora > go;
21343'# end loop;
21343'#
21343'# return true;
21343'# end;
21343'# ' language 'plpgsql';
CREATE
21343=#
21343=# select now(); select wait(5); select now();
now
-------------------------------
2003-07-23 15:45:46.754845-04
(1 row)
wait
------
t
(1 row)
now
-------------------------------
2003-07-23 15:45:51.758621-04
(1 row)
21343=#
21343=# select now(); select wait(10); select now();
now
-------------------------------
2003-07-23 15:45:58.713646-04
(1 row)
wait
------
t
(1 row)
now
------------------------------
2003-07-23 15:46:08.71887-04
(1 row)
Robert Treat
--
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2003-07-23 19:48 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-07-22 07:59 time delay function Girish Bajaj <gbajaj@tietronix.com>
2003-07-22 09:34 ` Peter Eisentraut <peter_e@gmx.net>
2003-07-22 08:22 Re: time delay function Christoph Haller <ch@rodos.fzk.de>
2003-07-23 19:48 ` Robert Treat <xzilla@users.sourceforge.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox