Testing DB to create a save point

Now when I test, if I create a db error, I wipe all the db clean and reenter.
Would love to see a way to specify the tables, and a point in time to save them. Then just recover those db values if the test fails

Your solution is probably, sc_begin_trans() and sc_commit_trans()

Not sure how that helps. I need to commit to see the results. How then do I restore t o the start point?

Commit is for all instance to see your change, you can test your data, do queries or what other test you want on your instance because it will be updated, then you do a commit if it’s ok.

If you are alone using the DB, you can easily do a function that will copy the tables you want, do your test and restore the tables if the result is not what you want.

save_table(table1, table2, table3, …);

Great, and what is function to restore the tables

If a remember well

To save a table to an other table

DROP TABLE xxxx_bak IF EXISTS;
CREATE TABLE xxxx_bak LIKE xxxx;
INSERT INTO xxxx_bak SELECT * FROM xxx;

To restore

TRUNCATE TABLE xxxx;
INSERT INTO xxxx SELECT * FROM xxxx_bak;

Just create an internal librairies in ScriptCase with 2 functions, save_table() and restore_table()
or some snippet

1 Like

TY, will definitely try this today