<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: id code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 03:41:27 GMT</pubDate>
    <description>DZone Snippets: id code</description>
    <item>
      <title>MSSQL 2005 - Add ID value to ID column when INSERTING </title>
      <link>http://snippets.dzone.com/posts/show/4521</link>
      <description>// @TableName is obviously the TABLE name u use&lt;br /&gt;// @ColumnName is obviously the COLUMN name u use&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;---Get next ID number&lt;br /&gt;	DECLARE &lt;br /&gt;		@ID int&lt;br /&gt;	&lt;br /&gt;	IF (SELECT count(*) FROM @TableName ) &gt; 0&lt;br /&gt;		BEGIN&lt;br /&gt;			SELECT @ID  = max(ColumnName ) from @TableName&lt;br /&gt;			SET @ID = @ID + 1 &lt;br /&gt;		END&lt;br /&gt;	ELSE&lt;br /&gt;	BEGIN&lt;br /&gt;		SET @ID  = 1&lt;br /&gt;	END&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 11 Sep 2007 07:50:29 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4521</guid>
      <author>dubby (Dave)</author>
    </item>
    <item>
      <title>IdGenerator in java</title>
      <link>http://snippets.dzone.com/posts/show/2615</link>
      <description>// IdGenerator&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;public class IdGenerator {&lt;br /&gt;	&lt;br /&gt;	private long maxId; &lt;br /&gt;	&lt;br /&gt;	public IdGenerator(long start) {&lt;br /&gt;		maxId = start;&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	public long getNextId () {&lt;br /&gt;		return ++maxId;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;} // IdGenerator&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 17 Sep 2006 19:34:56 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2615</guid>
      <author>ovhaag (Oliver Haag)</author>
    </item>
    <item>
      <title>Thai election ID checking</title>
      <link>http://snippets.dzone.com/posts/show/1716</link>
      <description>The online service &lt;a href=http://www.dopa.go.th/online/inqelect.htm&gt;here&lt;/a&gt; aims to help people&lt;br /&gt;check where they are to vote. However, it can be&lt;br /&gt;used as ID certification as well.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# nnnn is the id to be checked&lt;br /&gt;http://www.dopa.go.th/cgi-bin/inqelect.sh?pid=nnnn&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Here I make it into a function call.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;import urllib, re&lt;br /&gt;def getname(id):&lt;br /&gt;  url = 'http://www.dopa.go.th/cgi-bin/inqelect.sh?pid=' + str(id)&lt;br /&gt;  src = urllib.urlopen(url).read()&lt;br /&gt;  pat = '&lt;H3&gt; *(.*?) *&lt;'&lt;br /&gt;  name = re.findall(pat, src)[0]  # don't use other info&lt;br /&gt;  return name&lt;br /&gt;&lt;br /&gt;print getname(5100900050063)  # show a name (one of my relatives)&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 19 Mar 2006 16:30:32 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1716</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
    <item>
      <title>Get LAST_INSERT_ID from Symbian DBMS</title>
      <link>http://snippets.dzone.com/posts/show/1692</link>
      <description>&lt;code&gt;&lt;br /&gt;# table schema&lt;br /&gt;# CREATE TABLE person (id COUNTER, name VARCHAR)&lt;br /&gt;&lt;br /&gt;db = e32db.Dbms()&lt;br /&gt;db.begin()  # begin transaction (lock other inserts)&lt;br /&gt;db.execute(u"INSERT INTO person(name) VALUES 'korakot' ") # insert a new row&lt;br /&gt;&lt;br /&gt;dbv = e32db.Db_view()&lt;br /&gt;dbv.prepare(db, u"SELECT id FROM person ORDER BY id DESC")&lt;br /&gt;dbv.first_line()&lt;br /&gt;dbv.get_line()&lt;br /&gt;last_id = dbv.col(1)  # get it!&lt;br /&gt;&lt;br /&gt;db.commit()  # commit the transaction&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 13 Mar 2006 17:23:21 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1692</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
  </channel>
</rss>
