1. François Van Lerberghe
  2. Valentina Database ADK
  3. Воскресенье, Апрель 26 2020, 08:39 AM
  4.  Подписаться через email
Suppose an invoice creation. I have to
- add header data (customer, date, ...) in header table
- add details data (product, quantity, ...) in details table
- update stock in stock table
...
I want to be able to rollback things if something goes wrong in the middle of the process.
How can I do that with Valentina ? Is it possible ?
With other databases model, I have transactions and the associated command (BEGIN, END, COMMIT, ROLLBACK), but not in Valentina. How am I supposed to do ?
Комментарий
There are no comments made yet.
Ruslan Zasukhin Ответ принят
Hi Francois

Currently, VDB does not have rollback.
We need todo it.
Комментарий
There are no comments made yet.
François Van Lerberghe Ответ принят
I'm really wondering why such a basic and important function is not yet implemented. It seems to me that this lack does not give a professional image to Valentina engine...
I strongly encourage you to develop this feature as soon as possible.
Комментарий
There are no comments made yet.
Ivan Smahin Ответ принят
It could be something like this one:


CREATE TABLE t1 ( id LONG UNIQUE, f1 LONG );
CREATE TABLE t2 ( ptr LONG, f2 LONG UNIQUE, FOREIGN KEY (ptr) REFERENCES t1(id) );



CREATE OR REPLACE PROCEDURE sp1( IN inValue_id long, IN inValue_f1 long, IN inValue_f2 long )
BEGIN
INSERT INTO t1 VALUES( inValue_id, inValue_f1 );
BEGIN
INSERT INTO t2 VALUES( inValue_id, inValue_f2 );
EXCEPTION
WHEN OTHERS THEN
DELETE FROM t1 WHERE RecID = (SELECT last_recid_of_table('t1'));
RAISE;
END
END;



It works:


CALL sp1( 1, 11, 22 )


Now let's try to violate t2.f2 uniqueness. As a result - both tables are in a consistence state:


CALL sp1( 2, 111, 22 )
Комментарий
There are no comments made yet.
  • Страница :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.