473,385 Members | 1,311 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,385 software developers and data experts.

Logging Errors

SQL Server 2000 BE, Access 2002 FE.

I want to write a stored procedure, that will among other things log
errors to a table, I want to be able to report a summary of work done
and errors to the user and let them decide whether to commit or
rollback. I so far foresee a couple of problems.

1. Inside a transaction, I write to the error log table, will I be able
to read it back again before commit/rollback?

2. If I rollback, my error log gets rolled back too.

Is it possible to log the errors outside of the current transaction?
Jul 20 '05 #1
2 2409

"Trev@Work" <no.email@please> wrote in message
news:41***********************@news.easynet.co.uk. ..
SQL Server 2000 BE, Access 2002 FE.

I want to write a stored procedure, that will among other things log
errors to a table, I want to be able to report a summary of work done and
errors to the user and let them decide whether to commit or rollback. I so
far foresee a couple of problems.

1. Inside a transaction, I write to the error log table, will I be able to
read it back again before commit/rollback?

2. If I rollback, my error log gets rolled back too.

Is it possible to log the errors outside of the current transaction?


Yes, yes and no (assuming nothing like an extended proc, or writing to a
file outside the database). But in any case, keeping a transaction open
pending user input is not a good idea - sooner or later someone will go for
a coffee or lunch, leaving a transaction open and everyone else blocked. And
on top of that, many MSSQL errors can't be handled on the server side anyway
(if that's the kind of error you meant):

http://www.sommarskog.se/error-handling-I.html

I don't know exactly what you're doing, but you should probably retrieve the
data to the client, let the user review and update it there, then write it
back. You can use use a rowversion/timestamp column to detect if the data in
the base tables has changed between retrieving it and updating it.
Alternatively, you may be able to use application locks (see sp_getapplock)
in Books Online to define your own locking approach for your application.

If this isn't helpful, you might want to post some more details of what you
need to do, and what sort of errors you want to trap.

Simon
Jul 20 '05 #2
Simon Hayes wrote:
"Trev@Work" <no.email@please> wrote in message
news:41***********************@news.easynet.co.uk. ..
SQL Server 2000 BE, Access 2002 FE.

I want to write a stored procedure, that will among other things log
errors to a table, I want to be able to report a summary of work done and
errors to the user and let them decide whether to commit or rollback. I so
far foresee a couple of problems.

1. Inside a transaction, I write to the error log table, will I be able to
read it back again before commit/rollback?

2. If I rollback, my error log gets rolled back too.

Is it possible to log the errors outside of the current transaction?

Yes, yes and no (assuming nothing like an extended proc, or writing to a
file outside the database). But in any case, keeping a transaction open
pending user input is not a good idea - sooner or later someone will go for
a coffee or lunch, leaving a transaction open and everyone else blocked. And
on top of that, many MSSQL errors can't be handled on the server side anyway
(if that's the kind of error you meant):

http://www.sommarskog.se/error-handling-I.html

I don't know exactly what you're doing, but you should probably retrieve the
data to the client, let the user review and update it there, then write it
back. You can use use a rowversion/timestamp column to detect if the data in
the base tables has changed between retrieving it and updating it.
Alternatively, you may be able to use application locks (see sp_getapplock)
in Books Online to define your own locking approach for your application.

If this isn't helpful, you might want to post some more details of what you
need to do, and what sort of errors you want to trap.

Simon


Hi Simon, thanks for the reply. I'm doing an import, in this case an MTO
(Material Take Off from CAD into a procurement system). The errors I
will trap here are data errors, e.g. if a delta quantity would cause a
cumulative quantity to go below zero or the revision of a drawing being
imported is already in the drawing archive (i.e. they are importing an
older one than they should be).

I see your point about people going for coffee, I do it myself <g> I
have re-designed to take into account any locking problems associated
with transactions so that now I pre-process everything and mark the
imported records with error codes, I can then generate an error listing
before I even touch the live data.

Any other errors that occur (thanks for the link) I will be rolling back
everything anyway, the user will have to like it or lump it :-)
Jul 20 '05 #3

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

Similar topics

0
by: Pete Jereb | last post by:
Ok, I've managed to get the logging package to work, sort of. I'm writing a text parser, where data entry clerks can edit large, unwieldy and unforgiving textfiles that are VERY SENSITIVE as to...
8
by: A.M | last post by:
Hi, What would be the best approach to log different items (SQL, Exceptions, Security, ...) I have a simple Logging function that adds log string to the end of a text file. Is there any...
4
by: Denise | last post by:
I am trying to implement database error logging in my asp.net application. When I inspect the exception variable, I see that there is a property called 'procedure' which I believe is the procedure...
7
by: Leo Breebaart | last post by:
I have another question where I am not so much looking for a solution but rather hoping to get some feedback on *which* solutions people here consider good Pythonic ways to approach a issue. ...
7
by: flupke | last post by:
Hi, i'm getting errors with the log module concerning RotatingFileHandler. I'm using Python 2.4.3 on Windows XP SP2. This used to work in previous python versions but since i upgraded to 2.4.3...
0
by: rajesh.hanchate | last post by:
Please help me in resolving this issue. I am using EnterpriseLibrary 2.0 Exception and logging block for logging exceptions to event log. It works fine for sometime. After some time it stops...
3
by: nicholas.petrella | last post by:
I am currently trying to use the python logging system as a core enterprise level logging solution for our development and production environments. The rotating file handler seems to be what I...
4
by: Alexandru Mosoi | last post by:
why doesn't logging throw any exception when it should? how do I configure logging to throw exceptions? .... logging.fatal('asdf %d', '123') .... except: .... print 'this line is never...
6
by: Thomas Heller | last post by:
I'm using the logging module in my comtypes library to log 'interesting' things that happen. In other words, the idea is if the user of the library is interested in the details that happen in the...
1
by: arunairs | last post by:
Hi, Using the EnterpriseLibrary 4.0, is it possible to Log the method name in the log file. I have it cofigured thus: <loggingConfiguration name="Logging Application Block"...
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: 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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.