Article View: borland.public.interbase.sql
Article #147Re: insert into problem
From: Isaac
Date: Mon, 09 Jun 2008 23:10
Date: Mon, 09 Jun 2008 23:10
28 lines
2165 bytes
2165 bytes
Wayne Niddery (TeamB) wrote: > 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 > Thanks alot, appreciate your concern
Technical Details
Message-ID:
<484db79d@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.germany.com!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> <484d36f0@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 Date: Tue, 10 Jun 2008 02:10:09 +0300 From: Isaac <no@no.com> User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 Newsgroups: borland.public.interbase.sql Subject: Re: insert into problem 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> <484d36f0@newsgroups.borland.com> In-Reply-To: <484d36f0@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 41.234.199.16 Message-ID: <484db79d@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1213052829 41.234.199.16 (9 Jun 2008 16:07:09 -0700) Lines: 28 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail