title: Does SQLite have Cursors?
body: <p>i wonder if i could run the following procedure in SQLite:</p>
  
  <pre><code>set nocount on
  
  select T.ID, max(T.SerialNo) as SerialNo
  into #Tmp_Ticket_ID
  from Ticket as T, Ticket as inserted
  where t.ID = inserted.ID
  group by T.id having count(*) &gt; 1
  
  declare zeiger cursor for
      select SerialNo
      from #Tmp_Ticket_ID
  
  declare @SerialNo int
  
  OPEN Zeiger  
  FETCH NEXT FROM zeiger INTO @SerialNo 
  WHILE (@@fetch_status &lt;&gt; -1)  
  BEGIN  
      IF (@@fetch_status &lt;&gt; -2)  
      BEGIN  
          update T
              set ID = (select max(id) + 1 from Ticket)
          from ticket AS T, #Tmp_Ticket_ID as I
          where t.serialNo = i.serialno
          and I.Serialno = @SerialNo
      END
      FETCH NEXT FROM zeiger INTO @SerialNo
  END  
  CLOSE Zeiger  
  DEALLOCATE Zeiger  
  DROP TABLE #Tmp_Ticket_ID
  </code></pre>
  
  <p>This is a little procedure from a ms-sql2000 which cleans doubles of Ticket_id's in a given table Ticket of the following structur:</p>
  
  <pre><code>create table Ticket (serialNo int identity(1,1) not null
      , ID as int not null
      , Ticket_issue as varchar(50)
      , some_more_field varchar(500))
  </code></pre>
  
  <p>Due to a simple merger from different databases, the ticket_id's becomes not unique. To fix by renumbering this i developed this procedure but now we have a similar issue on a SQLite-db.</p>