I am trying to make rollback if something went wrong during the execution of my sql crud operations or if it can not make commit with shell scripting.
I have test2.sh and test.sh test.sh:
#!/bin/sh
sqlite3 dB.sqlite << EOF
begin;
select * from Table1;
and test2.sh
#!/bin/sh
if echo `./test.sh`|grep -q "SQL error"; then
rollback;
else
err=commit;
if echo $err |grep -q "error"; then
rollback;
fi
fi
There is no table called Table1 and i expected to get the sql error output of test.sh and rollback.
But it gives error : rollback: command not found. How can i get the error and make rollback? or Is this way that i follow right?