473,382 Members | 1,332 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Logging duration of batch runs

Hi,

I have a stored procedure run periodically that assign accounting records
to their respective customers based on username and other criteria.
It also does all kinds of validation work on the accounting records.

I would have liked to have the procedure log start and stop times
using RAISE NOTICE and also store start and stop time of each run
to a logging table.

I currently have following:

---snipp---
CREATE OR REPLACE FUNCTION radius.radius_acct_batch() RETURNS void
AS '
DECLARE
batch_id int;
realm RECORD;
start_time timestamp;
stop_time timestamp;
BEGIN
-- start new batch
start_time := ''now'';
INSERT INTO radius.radius_acct_batch ( radius_acct_batch_run_start ) VALUES ( start_time );
SELECT INTO batch_id currval(''radius.radius_acct_batch_radius_acct_bat ch_id_seq'');

RAISE NOTICE ''radius.radius_acct_batch, radius_acct_batch_id=%, start_time=%.'', batch_id, start_time;

-- do actual work

...
...
...
...
-- register end date in batch
stop_time := ''now'';
UPDATE radius.radius_acct_batch SET radius_acct_batch_run_end=stop_time WHERE radius_acct_batch_id=batch_id;
RAISE NOTICE ''radius.radius_acct_batch, radius_acct_batch_id=%, stop_time=%, done.'', batch_id, stop_time;

RETURN;
END'
LANGUAGE plpgsql;
---snipp---

the problem is that start_time and stop_time are identical.

Is there any way I can get plpgsql to reevaluate now at the end
of the batch ???

Greetings
Christian

--
Christian Kratzer ck@cksoft.de
CK Software GmbH http://www.cksoft.de/
Phone: +49 7452 889 135 Fax: +49 7452 889 136

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #1
3 1575
On Wed, Jun 23, 2004 at 12:49:19PM +0200, Christian Kratzer wrote:
Hi,

I have a stored procedure run periodically that assign accounting records
to their respective customers based on username and other criteria.
It also does all kinds of validation work on the accounting records.

I would have liked to have the procedure log start and stop times
using RAISE NOTICE and also store start and stop time of each run
to a logging table.
<snip>
the problem is that start_time and stop_time are identical.

Is there any way I can get plpgsql to reevaluate now at the end
of the batch ???
You want timeofday(), not now(). Now() is transaction time, timeofday()
is the real current time.

Hope this helps,
--
Martijn van Oosterhout <kl*****@svana.org> http://svana.org/kleptog/ Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
tool for doing 5% of the work and then sitting around waiting for someone
else to do the other 95% so you can sue them.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFA2WrEY5Twig3Ge+YRAqquAJ4w/UWwyveqDwGTcFJHZZLLmzjC5ACdGYCj
IUVh/4aZXgU+7hQLVlmDHGU=
=4b1V
-----END PGP SIGNATURE-----

Nov 23 '05 #2
Hi,
j
On Wed, 23 Jun 2004, Martijn van Oosterhout wrote:
On Wed, Jun 23, 2004 at 12:49:19PM +0200, Christian Kratzer wrote:
Hi,

I have a stored procedure run periodically that assign accounting records
to their respective customers based on username and other criteria.
It also does all kinds of validation work on the accounting records.

I would have liked to have the procedure log start and stop times
using RAISE NOTICE and also store start and stop time of each run
to a logging table.


<snip>
the problem is that start_time and stop_time are identical.

Is there any way I can get plpgsql to reevaluate now at the end
of the batch ???


You want timeofday(), not now(). Now() is transaction time, timeofday()
is the real current time.


thankx! That did it ...

Greetings
Christian

--
Christian Kratzer ck@cksoft.de
CK Software GmbH http://www.cksoft.de/
Phone: +49 7452 889 135 Fax: +49 7452 889 136

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #3
Christian Kratzer wrote:
Hi,

I have a stored procedure run periodically that assign accounting
records to their respective customers based on username and other criteria.
It also does all kinds of validation work on the accounting records.

I would have liked to have the procedure log start and stop times using
RAISE NOTICE and also store start and stop time of each run
to a logging table. [snip] Is there any way I can get plpgsql to reevaluate now at the end
of the batch ???


You want timeofday() rather than now(). Note that it returns text rather
than a timestamp.

--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bucky Pollard | last post by:
I have a web service that needs to create a batch file and call it (since there are no APIs for the functionality I am looking for). I am using the Process and ProcessStartInfo objects. When I try...
6
by: Charles Neitzel | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
1
by: Charles | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
2
by: Ericson Smith | last post by:
Hi, Currently we are logging SQL statements for profiling purposes. We now get something like this: 2004-05-26 13:27:51 LOG: statement: SELECT * FROM cache_62 WHERE...
2
by: Stephen | last post by:
Hi all, I want to create an app that runs a batch file which inturn runs applications. question: if I start the batch file from app1, how can app1 know that the batch file ran successfully...
26
by: mvdkwong | last post by:
What's the trick to running a batch file from VBA? I'm trying to call it using the Shell function but it's not working for me. If I double-click the batch file or run it from the command line it...
4
ck9663
by: ck9663 | last post by:
hi guys this is a little challenging, at least for me...here goes... i have to run a DOS batch file from a server. with some parameters that i need to pass. these parameters can be found on a...
2
by: scriptlearner | last post by:
OS: Solaris 9 Python Version: 2.4.4 I need to log certain data in a worker thread; however, I am getting an error now when I use two worker threads. I think the problem comes from the line...
3
by: scriptlearner | last post by:
I am trying to put up a queue (through a logging thread) so that all worker threads can ask it to log messages. However, the problem I am facing is that, well, the logging thread itself is running...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.