Article View: borland.public.interbase.sql
Article #140Re: insert into problem
From: Wayne Niddery (TeamB)
Date: Mon, 09 Jun 2008 13:57
Date: Mon, 09 Jun 2008 13:57
33 lines
2531 bytes
2531 bytes
"Isaac" <no@no.com> wrote in message news:484d2e33@newsgroups.borland.com...
>>
> Ok, can you please tell me what you mean by setting one of the fields to
> itself
update mytable set myid = myid where myid = x
Locking as suggested by Bill requires the application to do two things:
1. Proper use of transactions
2. Handling the exception when the above SQL fails due to another user
having it locked
Pseudocode would be:
start transaction // must be read committed
try
update mytable set myid = myid where myid = x
select max(itemnum) from mytable where myid = x
newitemnum := fields[itemnum] + 1
insert into mytable (myid, itemnum, ...) values (x, newitemnum, ...)
commit transaction
except
// decide how to handle other user having this record locked already
// could just go back around and try again since it should not be
long
// or can rollback transaction and inform the user to try again
later
end
--
Wayne Niddery - TeamB (www.teamb.com)
Winwright, Inc. (www.winwright.ca)
Technical Details
Message-ID:
<484d36f0@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<484b07da@newsgroups.borland.com> <484b16e4@newsgroups.borland.com> <484b52eb$1@newsgroups.borland.com> <484c007f@newsgroups.borland.com> <484c07a9$1@newsgroups.borland.com> <484c2394@newsgroups.borland.com> <484c7832$1@newsgroups.borland.com> <484d14e3$1@newsgroups.borland.com> <484d280b$1@newsgroups.borland.com> <484d2e33@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,ed255c09332ecd2c X-Google-Attributes: gid114a0e,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Wayne Niddery \(TeamB\)" <wniddery@chaffaci.on.ca> Newsgroups: borland.public.interbase.sql References: <484b07da@newsgroups.borland.com> <484b16e4@newsgroups.borland.com> <484b52eb$1@newsgroups.borland.com> <484c007f@newsgroups.borland.com> <484c07a9$1@newsgroups.borland.com> <484c2394@newsgroups.borland.com> <484c7832$1@newsgroups.borland.com> <484d14e3$1@newsgroups.borland.com> <484d280b$1@newsgroups.borland.com> <484d2e33@newsgroups.borland.com> In-Reply-To: <484d2e33@newsgroups.borland.com> Subject: Re: insert into problem Date: Mon, 9 Jun 2008 09:57:52 -0400 Lines: 34 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Windows Mail 6.0.6001.18000 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18000 NNTP-Posting-Host: 24.137.214.213 Message-ID: <484d36f0@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1213019888 24.137.214.213 (9 Jun 2008 06:58:08 -0700) X-Authenticated-User: wniddery Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail