title: Commit transactions if no error,rollback if error occured in Oracle SQL* plus
body: <p>Following is small block of code i use to deploy the SQL scripts in my databases. I'm just wondering if i can automate this task of commit or rollback based in the result.</p>
  
  <pre><code>disc
  connect username/password@database
  spool D:\Deployments\path\to\logfile\logfile.log
  @D:\Deployments\path\to\script\sqlquery_script.sql
  </code></pre>
  
  <p>If the sql script is ran successfully with out any errors means I want the system to Commit it automatically and in case any error is occcured all teh transactions should be rollbacked (Note that my sql script has many update statements)</p>
  
  <p>When I use <code>WHENEVER SQLERROR EXIT SQL.CODE ROLLBACK;</code> the SQL* plus window is closed without showing any error.</p>
  
  <p>Please help to resolve this.</p>