Re: time delay function
Re: time delay function
От:
Robert Treat <xzilla@users.sourceforge.net>
Дата:
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
time delay function
От:
"Girish Bajaj" <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 continuing to execute the next sql statment? Thanks, Girish
Re: time delay function
От:
Christoph Haller <ch@rodos.fzk.de>
Дата:
> > 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
Re: time delay function
От:
Peter Eisentraut <peter_e@gmx.net>
Дата:
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