🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: free.it.visual-basic
Article #2262

Re: ADO.NET - Bloccare la lettura di una tabella

#2262
From: Netslacker
Date: Thu, 26 Jun 2003 10:38
40 lines
3070 bytes
"Raffaele Rialdi" <malta@n0spam_vevy.com> ha scritto nel messaggio
news:eEyXRB1ODHA.1608@TK2MSFTNGP11.phx.gbl...
> Io intendevo uno statement Update (da lanciare in un command) che
verifichi
> nella clausola where che ci sia un residuo da pagare.
> Nell'esempio che segue, do per scontato che stai lavorando con sql server,
> ma la cosa � adattabile con altri db.
>
> Puoi fare per esempio un command (o anche una stored procedure) con questa
> unica query separata da ;
>
> declare @Tot as integer;
> select @Tot = SUM(Importo) from MyTable where Commessa= @Id;
> update MyTable set Importo = @Tot - @Pagamento from MyTable
>    where Commessa= @Id and (@Tot > @Pagamento)
>
>
> Nel command devi aggiungere i due parameters:
> * @Id che � l'id della commessa (adattalo al tuo caso)
> * @Pagamento che � l'importo che vorresti pagare
> Il parametro @Tot rimane una variabile interna alla procedura che serve
per
> calcolare il totale parziale e verificare che ci sia abbastanza Importo
> residuo da pagare (dovrai poi tu adattarlo a seconda se Importo
rappresenta
> il dare o l'avere).
> Se la where � soddisfatta allora esegue l'aggiornamento, altrimenti non fa
> nulla.
>
> Usando un solo command quella query � 'atomica'. Se dovessi eseguire pi�
> aggiornamenti, dovresi aprire e richiudere una transazione. A quel punto
ti
> conviene sicuramente buttare tutto dentro una stored procedure.
>

Grazie mille, ora ci provo. Ma per gli inserimenti di nuovi record ? La
procedura � uguale? cio� un insert con una select prima ?

ciao e grazie ancora
Technical Details
Message-ID: <G2AKa.123431$lK4.3461997@twister1.libero.it>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.infostrada.it!twister1.libero.it.POSTED!not-for-mail
References: <8W%Ia.108224$Ny5.3122798@twister2.libero.it> <#hbR2bQODHA.2172@TK2MSFTNGP10.phx.gbl> <4oAJa.111908$Ny5.3241362@twister2.libero.it> <OQBUGbdODHA.2228@tk2msftngp13.phx.gbl> <LXaKa.119763$lK4.3387350@twister1.libero.it> <eEyXRB1ODHA.1608@TK2MSFTNGP11.phx.gbl>

Show Full Headers
Complete Article Headers
X-Google-Language: ITALIAN,ASCII
X-Google-Thread: f94ee,fa2856aabc00a4a8
X-Google-Attributes: gidf94ee,public
X-Google-Thread: 10b997,fa2856aabc00a4a8
X-Google-Attributes: gid10b997,public
X-Google-Thread: 10c104,fa2856aabc00a4a8
X-Google-Attributes: gid10c104,public
X-Google-ArrivalTime: 2003-06-26 03:40:21 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.infostrada.it!twister1.libero.it.POSTED!not-for-mail
From: "Netslacker" <netslacker@iname.com>
Newsgroups: free.it.visual-basic,it.comp.lang.visual-basic,microsoft.public.it.dotnet.vstudio
References: <8W%Ia.108224$Ny5.3122798@twister2.libero.it> <#hbR2bQODHA.2172@TK2MSFTNGP10.phx.gbl> <4oAJa.111908$Ny5.3241362@twister2.libero.it> <OQBUGbdODHA.2228@tk2msftngp13.phx.gbl> <LXaKa.119763$lK4.3387350@twister1.libero.it> <eEyXRB1ODHA.1608@TK2MSFTNGP11.phx.gbl>
Subject: Re: ADO.NET - Bloccare la lettura di una tabella
Lines: 42
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Message-ID: <G2AKa.123431$lK4.3461997@twister1.libero.it>
Date: Thu, 26 Jun 2003 10:38:30 GMT
NNTP-Posting-Host: 151.37.71.87
X-Complaints-To: abuse@net24.it
X-Trace: twister1.libero.it 1056623910 151.37.71.87 (Thu, 26 Jun 2003 12:38:30 MET DST)
NNTP-Posting-Date: Thu, 26 Jun 2003 12:38:30 MET DST
Organization: [Infostrada]