title: using declare cursor with cx_oracle
body: <p>I am trying to parse an sqlscript file based on a delimiter ";" and then subsequently call Cx_Oracle to connect and execute statements on the DB server. I have run into an issue with a cursor related block of code. My call structure is thus:</p>
  
  <pre><code> ScriptHandle = open(filepath)
   SqlScript = ScriptHandle.read()
   SqlCommands = SqlScript.split(';')
      for sqlcommand in SqlCommands:
          print sqlcommand,'\n'*3
          if sqlcommand:  
              ODBCCon.ExecuteWithCx_Oracle(cursor, sqlcommand)
  </code></pre>
  
  <p>The problem I have comes with the following sql block:</p>
  
  <pre><code>DECLARE CURSOR date_cur IS (select calendar_date 
          from cg_calendar dates
          where dates.calendar_date between '30-Jun-2014' and '31-Jul-2015'
          and global_business_or_holiday = 'B');
  
  BEGIN
  FOR date_rec in date_cur LOOP
  insert into fc_pos
  SELECT PP.acctid,
          PP.mgrid,
          PP.activitydt,
          PP.secid,
          PP.shrparamt,
          PP.lclmktval,
          PP.usdmktval,
          SM.asset_name_1,
          SM.asset_name_2,
          SM.cg_sym,
          SM.fc_local_crncy_cd,
          SM.fc_local_crncy_id,
          SM.fc_trade_cd,
          substr(SM.asset_name_1, 17,3) as against_crncy_cd
      FROM FC_acct_mgr AM, asset SM, ma_mktval PP
  WHERE PP.dw_asset_id = SM.dw_asset_id
  AND PP.secid = SM.asset_id
  AND PP.activitydt = date_rec.calendar_date
  AND AM.acctid = PP.acctid
  AND AM.mgrid = PP.mgrid
  AND SM.asset_categ_cd = 'FC';
  END LOOP;
  END;
  </code></pre>
  
  <p>The above python parse step disassociates the above code based on delimiter ";" where as I need to treat above as one block starting at the DECLARE and ending at the END;</p>
  
  <p>How can I accomplish it from python end. I have been unable to make any headway on this and this is a legacy process flow that I am automating.</p>
  
  <p>Thanks in advance.</p>