(Mortar)
3/20/2007 11:51:00 AM
No, the table I am deleting from is not referenced in a relationship by
another table.
"Someone Else" <someone_else_of_course@hotmail.co.uk> wrote in message
news:1174380921.756798.78970@b75g2000hsg.googlegroups.com...
> The only way I can see that could fail is a foreign key constraint
> being violated - any of those exist?
>
> On 20 Mar, 02:25, "AC" <a...@b.com> wrote:
>> Thanks! I'm certain it fails on that DELETE query I initially posted.
>>
>> No triggers are run on delete on the table being deleted.
>>
>> Problem is our client has no tools to do any investigation, and they do
>> not
>> have IT staffs. They are golf professionals that are 3000 miles away
>> unfortunately. We have a part of our app that backs up the DB and ftp's
>> it
>> to our site so I can examine which is how I saw the data. They sent
>> their
>> "error file" as well but there was no error in the file on the time it
>> happened. When the DB comes to us, it's truncated so it's small since
>> most
>> users do not have broadband.
>>
>> Our DB at 4am had a problem because of this routine not running fully
>> which
>> ran at midnight, or close to it (our app is always up, and when the day
>> changes, it sees if it needs to run this).
>>
>> "Tom Moreau" <t...@dont.spam.me.cips.ca> wrote in message
>>
>> news:Ozcp1OpaHHA.2436@TK2MSFTNGP06.phx.gbl...
>>
>>
>>
>> > I'd be tempted to run a profiler trace here, getting the statements
>> > that
>> > begin and those that complete. We need to narrow down the exact piece
>> > of
>> > code that's acting up. Pay attention also to the SPID that fails and
>> > any
>> > other SPIDs that are running at the same time.
>>
>> > --
>> > Tom
>>
>> > ----------------------------------------------------
>> > Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
>> > SQL Server MVP
>> > Toronto, ON Canada
>> > .
>> > "AC" <a...@b.com> wrote in messagenews:NaHLh.454$zo.143@newsfe12.lga...
>> > The cursor is in play (I wrote the code) because was a series of
>> > actions
>> > need to take place once a month (actually once a revision, but let's
>> > say,
>> > as
>> > it is in this case, that is once a month). About 8 stored procs are
>> > run
>> > for
>> > each record in the CLUB table. Some of them are doing calculations to
>> > keep
>> > history (the players handicap when the revision was set), and the
>> > PlayerRevisionScores is the list of scores to make the calculation, and
>> > they
>> > are stored in an audit area as well. There is more to it than just
>> > this,
>> > so
>> > it's not possible to simplify. The code is pretty optimized already.
>> > It's
>> > not possible to do this without the cursor
>>
>> > There shouldn't be anything else hitting the database when this is
>> > running
>> > at 12:00 (or shortly thereafter). It's run on Desktop Edition, which
>> > we
>> > install for them, and only our app hits the DB. At midnight, users are
>> > not
>> > using this (I can guarantee that), and even so, the table being deleted
>> > is
>> > an audit table...
>>
>> > Basically, this is what happens
>>
>> > Club returns 2 rows:
>> > 1st row (ClubID = 1)
>> > * RevisionID needed to be used is calculated (there is a series of
>> > 3)
>> > * PlayerRevisionScores is cleaned for the given ClubID for OLDER
>> > revisions (that's the query I showed
>> > * Tables for audit history are populated
>> > * Club table is updated with the revision ID so we do not run this
>> > again until next revision (its possible the PC is turned off for days,
>> > so
>> > we need to keep track of the revision we last run)
>> > * Revision table is cleaned out for all revisions 13 months old or
>> > older to keep DB size small
>>
>> > 2nd row (ClubID =2)
>> > * RevisionIDs are calculated
>> > * PlayerRevisionScores are attempted to be cleaned, but this never
>> > happens, and stored proc exits, as nothing else is run
>>
>> > As you can see, there are 5 steps, simpifying them of course, that need
>> > to
>> > be run. ClubID=1 works perfectly, then it loops around to run the same
>> > code
>> > for ClubID=2 and the 2nd step fails, and nothing else is run. The
>> > query
>> > for
>> > the 2nd step is what I showed before.
>>
>> > "Tom Moreau" <t...@dont.spam.me.cips.ca> wrote in message
>> >news:u8NibvoaHHA.1296@TK2MSFTNGP02.phx.gbl...
>> >> Is it possible to run just the SQL without any client code involved?
>> >> Also,
>> >> do you know why they're using a cursor? Are there any blocking
>> >> processes?
>>
>> >> --
>> >> Tom
>>
>> >> ----------------------------------------------------
>> >> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
>> >> SQL Server MVP
>> >> Toronto, ON Canada
>> >> .
>> >> "AC" <a...@b.com> wrote in messagenews:riGLh.84$Nv4.26@newsfe12.lga...
>> >> I wish I knew! It's failing at clients without error messages, or at
>> >> least
>> >> they aren't reporting any.... Our app tracks them too and I see none.
>>
>> >> The stored proc runs once, every month at midnight of the 1st. The
>> >> top
>> >> of
>> >> the proc is a cursor, and in this client's install, the cursor always
>> >> returns 2 rows, so the same stuff runs for both rows. The 1st row is
>> >> run
>> >> to
>> >> completion (about 6-7 calls) but the 2nd one stops here (this is the
>> >> 3rd
>> >> call). I checked thre data and figured it's stopping here. We have
>> >> about
>> >> 5
>> >> clients with this... and it doesn;'t happen every time either.
>> >> However,
>> >> when it fails here, 3-4 more SPs do not run...
>>
>> >> "Tom Moreau" <t...@dont.spam.me.cips.ca> wrote in message
>> >>news:O8kN7koaHHA.348@TK2MSFTNGP02.phx.gbl...
>> >>> When you say "fail", what exactly is the error message?
>>
>> >>> --
>> >>> Tom
>>
>> >>> ----------------------------------------------------
>> >>> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
>> >>> SQL Server MVP
>> >>> Toronto, ON Canada
>> >>> .
>> >>> "AC" <a...@b.com> wrote in
>> >>> messagenews:z_FLh.81$Nv4.49@newsfe12.lga...
>> >>> DELETE
>> >>> FROM PlayerRevisionScores
>> >>> WHERE RevisionID IN (SELECT RevisionID
>> >>> FROM Revision
>> >>> WHERE RevisionDate < (SELECT RevisionDate FROM Revision WHERE
>> >>> RevisionID = @nRev)
>> >>> AND ClubID = @nClubID)
>>
>> >>> Revision Table - Primary Key is RevisionID, an Integer.
>>
>> >>> Player Revision Scores, Primary Key is PlayerID and RevisionID.
>>
>> >>> Subquery has no shot of returning more than 1 value, as RevisionID is
>> >>> the
>> >>> PK...
>>
>> >>> PlayerRevisionScores has about 14000 rows in the 1 case where it
>> >>> fails,
>> >>> and
>> >>> while this query doesn't HAVE TO remove all rows, it is, int his
>> >>> installation, going to remove all 14000 rows most times... However,
>> >>> to
>> >>> handle all scenarios, the logic in place is accurate.- Hide quoted
>> >>> text -
>>
>> - Show quoted text -
>
>