Solved

Delphi 7 - Transaction whit devart component

Posted on 2010-11-12
8
691 Views
Last Modified: 2012-05-10
hi,
I created an application that must work in a local network.
Consider the creation of a invoice, when I create, a transaction begins with the component of TMyConnection Devart-CoreLab, from the ARTICOLI table confirm the selected row be reported in the invoice, if in another computer do the same thing, until the first computer I do not close the transaction, the second computer can not do anything.
0
Comment
Question by:danz67
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 34120364
Don't leave your transactions open. Any updates handled in a transaction should be committed immediately otherwise all other users attempting to update the table are locked out.
0
 

Author Comment

by:danz67
ID: 34121615
I know, I leave the transaction open because when I do an invoice and select a record from the ARTICOLI table, the stock must decrease, then if I decide to cancel the bill should not decrease the stock. If I close the transaction soon as you say, the stock is reduced and then decide to cancel the invoice do I do?
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 34129762
oracle is by default read-committed

so until your transaction is finished nobody else will see the pending stock changes

you could solve it with an additional table to add the pending stock changes in a autonomuous transaction
> user A
start tran 1
create invoice A1
Add stock article A100 to invoice for 200 amount
>> in auto tran, add record to pending_stock_change table for this article

if user B already created a new invoice too and you want to warn or warn anybody of the pending stock changes
you need to setup a system to look for any changes in the pending_stock_change table

you could show the pending changes to the other users like this
you need to use threading for this to work adequatly

0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 250 total points
ID: 34132056


Dont start transaction initially
Make all your changes in memory datasets that reflect your actual tables in the db
When you are ready to save your invoice,

start the transaction
  Create the invoice
  Reduce stock amount
  Commit transaction
if exception occures
  roll back transaction  //all data you changed is rolled back so you dont have incosistency
  raise the error
end
0
 

Author Comment

by:danz67
ID: 34134297
mmm ...
Now i run a stored procedure for recuce stock, I think the best solution is to create a stored procedure to cancel the reduce stock, if I cancel the invoice.

I created the procedure works on each record concerned enough to change ... instead of decreasing the quantity, needs to be increased, the only problem is that I should do this on all rows in the invoice via mysql and I do not know how.
I enclose the procedure I use for the drain (to change)




CREATE DEFINER = 'root'@'localhost' PROCEDURE `SCARICA_DISPONIBILITA`(
        IN idarticolo INTEGER(11),
        IN idmagazzino INTEGER(11),
        IN quantita DECIMAL(15,3)
    )
    NOT DETERMINISTIC
    CONTAINS SQL
    SQL SECURITY DEFINER
    COMMENT ''
BEGIN
     UPDATE `giacenze` SET `giacenze`.`disponibilita` = `giacenze`.`disponibilita` - quantita
     WHERE `giacenze`.`idarticolo` = idarticolo AND `giacenze`.`idmagazzino` = idmagazzino;
END;

Open in new window

0
 

Author Comment

by:danz67
ID: 34134361
I think we should create a loop inside the procedure that scans all the records contained in the bill (table dettfattura)

...
 ''in delphi i use this WHILE NOT dettfattura.EOF do
   update table....
   dettfattura.NEXT''

in mysql what???

0
 
LVL 100

Expert Comment

by:mlmcc
ID: 34700453
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question