<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Artful Code &#187; sql</title>
	<atom:link href="http://www.artfulcode.net/tags/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.artfulcode.net</link>
	<description>Resources and tips for dynamic, interactive languages.</description>
	<lastBuildDate>Fri, 09 Sep 2011 02:15:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>A better MySQL module for newLISP</title>
		<link>http://www.artfulcode.net/articles/a-better-mysql-module-for-newlisp/</link>
		<comments>http://www.artfulcode.net/articles/a-better-mysql-module-for-newlisp/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 17:23:32 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[foop]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[newlisp]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.artfulcode.net/?p=491</guid>
		<description><![CDATA[The Mysql module has been written from scratch utilizing some of the more recent features of newLisp, such as FOOP and reference returns. One of its major design goals was to simplify use as well as broaden the features of the standard MySQL module, while at the same time allowing the creation of new, anonymous [...]]]></description>
			<content:encoded><![CDATA[<p>The <strong><code>Mysql</code></strong> module has been written from scratch utilizing some of the more recent features of newLisp, such as FOOP and reference returns. One of its major design goals was to simplify use as well as broaden the features of the standard <a href="http://www.newlisp.org/code/modules/mysql.lsp.html">MySQL module</a>, while at the same time allowing the creation of new, anonymous instances at run-time.<span id="more-491"></span></p>
<p>The <code>Mysql</code> module differs from the distribution standard module in several important ways. Most obviously, it uses <a href="http://www.artfulcode.net/articles/using-the-newlisp-ffi/">FOOP wrappers for MySQL types</a>. It also requires clients to free results instances; in the standard module, only the base MYSQL instance itself must be freed (using <code>MySQL:close-db</code>).</p>
<p>The significance of this is that it is much simpler to create multiple connections (without having to duplicate the entire context at compile time). Result sets are completely independent of each other, and several may be maintained in any state at once. This also means that a spawned process may be given its own Mysql instance to use without having to worry about other processes&#8217; instances interfering. Using the standard module, the entire context would need to be cloned at compile time and given a static symbol reference (e.g., <code>(new 'MySQL 'db)</code>) in order to run multiple instances or connections to a server.</p>
<p>Moreover, because this module uses <code>unpack</code> and MySQL C API accessor functions, there is no need for the client to calculate member offsets in MySQL compound types. So long as newLisp was compiled for the same target as the <code>libmysqlclient</code> library (both are 32 bit or both are 64 bit), everything should work out of the box. Additionally, MySQL errors are now checked in the connect and query functions and re-thrown as interpreter errors. Instead of checking for <code>nil</code> returns and a using MySQL:error to get the error message, standard error  handling with the <code>catch</code> function may be used.</p>
<p>Several convenience functions and macros have been defined in the <code>mysql</code> context for common operations, including connecting to the database and iterating over results without having to worry about catching errors and managing memory. SQL statements may be passed as strings or a list containing a format string and its parameters, which will type-checked and automatically be escaped as needed.</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>mysql<span style="color: #66cc66;">:</span><span style="color: #555;">on-connect</span> '<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;localhost&quot;</span> <span style="color: #ff0000;">&quot;user&quot;</span> <span style="color: #ff0000;">&quot;secret&quot;</span> <span style="color: #ff0000;">&quot;my_database&quot;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>db err<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> err
      <span style="color: #66cc66;">&#40;</span>println <span style="color: #ff0000;">&quot;Error! &quot;</span> err<span style="color: #66cc66;">&#41;</span>
      <span style="color: #66cc66;">&#40;</span>mysql<span style="color: #66cc66;">:</span><span style="color: #555;">row-iter</span> db <span style="color: #ff0000;">&quot;SELECT * FROM some_table&quot;</span> true
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>row<span style="color: #66cc66;">&#41;</span>
          <span style="color: #66cc66;">&#40;</span>println row<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>This module has been tested with MySQL version 5 and 5.1 and newLisp version 10.0.1. It requires newLisp 10.0 or later. You can <a href="http://static.artfulcode.net/newlisp/mysql.lsp.html">download it</a> from the <a href="http://static.artfulcode.net/newlisp/">Artful Code newLisp module repository</a>.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Submit article</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fa-better-mysql-module-for-newlisp%2F&amp;title=A+better+MySQL+module+for+newLISP" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fa-better-mysql-module-for-newlisp%2F&amp;title=A+better+MySQL+module+for+newLISP" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=A+better+MySQL+module+for+newLISP&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fa-better-mysql-module-for-newlisp%2F&amp;title=A+better+MySQL+module+for+newLISP" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fa-better-mysql-module-for-newlisp%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fa-better-mysql-module-for-newlisp%2F&amp;title=A+better+MySQL+module+for+newLISP" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fa-better-mysql-module-for-newlisp%2F&amp;title=A+better+MySQL+module+for+newLISP" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fa-better-mysql-module-for-newlisp%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+A+better+MySQL+module+for+newLISP+@+http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fa-better-mysql-module-for-newlisp%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.artfulcode.net/articles/a-better-mysql-module-for-newlisp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Full-text searching with MySQL</title>
		<link>http://www.artfulcode.net/articles/full-text-searching-mysql/</link>
		<comments>http://www.artfulcode.net/articles/full-text-searching-mysql/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 16:30:00 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.artfulcode.net/articles/full-text-searching-mysql/</guid>
		<description><![CDATA[MySQL&#8217;s full-text search functions provide a simple framework for an easily implemented, approximate site search. Many sites, written in an interpreted language and powered by MySQL, can use MySQL&#8217;s full-text search to avoid third party dependencies. The basics The basics of the MySQL full-text search functions are well-documented in the MySQL online documentation. For those [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL&#8217;s full-text search functions provide a simple framework for an easily implemented, approximate site search.  Many sites, written in an interpreted language and powered by MySQL, can use MySQL&#8217;s full-text search to avoid third party dependencies.<span id="more-11"></span></p>
<h4>The basics</h4>
<p>The basics of the MySQL full-text search functions are <a href="http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html">well-documented</a> in the MySQL online documentation.  For those lacking patience, here is a quick rundown.</p>
<p>Full-text searching is somewhat akin to a <code>LIKE</code> condition, but is much faster, requiring a <code>FULLTEXT</code> index to be created for the table columns targeted in the search.  To search the <code>title</code> and <code>description</code> columns of a table, <code>entries</code>, the following statement would create the proper index:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> entries <span style="color: #993333; font-weight: bold;">ADD</span> FULLTEXT<span style="color: #66cc66;">&#40;</span>title<span style="color: #66cc66;">,</span> description<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>To search these columns for the text, &#8220;python threading,&#8221; the <code>MATCH...AGAINST</code> functions are used:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> id<span style="color: #66cc66;">,</span> MATCH<span style="color: #66cc66;">&#40;</span>title<span style="color: #66cc66;">,</span> description<span style="color: #66cc66;">&#41;</span> AGAINST <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'python threading'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> score
<span style="color: #993333; font-weight: bold;">FROM</span> entries
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> score <span style="color: #993333; font-weight: bold;">DESC</span></pre></div></div>

<p>Notice that we keep the result of the match.  The value returned is a float representing the relevance of the match.  The higher the number, the more relevant the match.</p>
<p>There are several caveats to the full-text search.  In particular, any words that are common between many entries are treated as noise and their relevance in any search is diminished.  This means that were every article in <code>entries</code> to be about threading in Python, searching for &#8220;python threading&#8221; may not return extremely relevant results.  Refer to the <a href="http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html">MySQL</a> docs for more information.</p>
<h4>The hard part</h4>
<p>If the content to be searched is not conveniently located in one table, things get more complex.  In this case, a method must be devised to create an intermediary table to contain the search target.</p>
<p>This might be accomplished with a cron script that aggregates the information nightly or using stored procedures to keep the target table updated.</p>
<h4>Refining results</h4>
<p>A common case is to weight the search to favor more recent results.  Assuming that each entry has a <code>DATETIME</code> field named <code>timestamp</code>, this is easily accomplished by using the entry&#8217;s age to modify the score.</p>
<p>For an even reduction to the score based on the article&#8217;s age, divide the score by the age, which is determined with <code>DATEDIFF(NOW(), timestamp)</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>MATCH<span style="color: #66cc66;">&#40;</span>title<span style="color: #66cc66;">,</span> description<span style="color: #66cc66;">&#41;</span> AGAINST <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'python threading'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span>GREATEST<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> DATEDIFF<span style="color: #66cc66;">&#40;</span>NOW<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> timestamp<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Since <code>DATEDIFF</code> returns the difference in days, an entry written today could cause division by zero.<br />
<code>GREATEST</code> means that entries written today and yesterday have equal weight, but prevents results from omitting today&#8217;s articles.</p>
<p>A quick test of this will show that results become wildly incorrect after a few days as the text match score begins to diminish further with age.  This effect can be reduced by taking the <code>LOG</code> of the age, making the divisor increase less and less the greater the age.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">LOG<span style="color: #66cc66;">&#40;</span>GREATEST<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> DATEDIFF<span style="color: #66cc66;">&#40;</span>NOW<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> timestamp<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>The use of <code>LOG</code> causes a steep drop initially, smothing over time.  For a less dramatic effect, substituting the square root causes a similar drop in the weight of the entry&#8217;s age over time, but diminishing less starkly over time and without the initial steep drop.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">SQRT<span style="color: #66cc66;">&#40;</span>GREATEST<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> DATEDIFF<span style="color: #66cc66;">&#40;</span>NOW<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> timestamp<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>The complete SQL statement is now:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> id<span style="color: #66cc66;">,</span>
  <span style="color: #66cc66;">&#40;</span>MATCH<span style="color: #66cc66;">&#40;</span>title<span style="color: #66cc66;">,</span> description<span style="color: #66cc66;">&#41;</span> AGAINST <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'python threading'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span>SQRT<span style="color: #66cc66;">&#40;</span>GREATEST<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> DATEDIFF<span style="color: #66cc66;">&#40;</span>NOW<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> timestamp<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #993333; font-weight: bold;">AS</span> score
<span style="color: #993333; font-weight: bold;">FROM</span> entries
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> score <span style="color: #993333; font-weight: bold;">DESC</span></pre></div></div>

<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Submit article</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Ffull-text-searching-mysql%2F&amp;title=Full-text+searching+with+MySQL" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Ffull-text-searching-mysql%2F&amp;title=Full-text+searching+with+MySQL" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Full-text+searching+with+MySQL&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Ffull-text-searching-mysql%2F&amp;title=Full-text+searching+with+MySQL" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Ffull-text-searching-mysql%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Ffull-text-searching-mysql%2F&amp;title=Full-text+searching+with+MySQL" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Ffull-text-searching-mysql%2F&amp;title=Full-text+searching+with+MySQL" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Ffull-text-searching-mysql%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Full-text+searching+with+MySQL+@+http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Ffull-text-searching-mysql%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.artfulcode.net/articles/full-text-searching-mysql/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Making 64-bit MySQL work with newLISP</title>
		<link>http://www.artfulcode.net/articles/making-64-bit-mysql-work-newlisp/</link>
		<comments>http://www.artfulcode.net/articles/making-64-bit-mysql-work-newlisp/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 17:49:47 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[newlisp]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.artfulcode.net/articles/making-64-bit-mysql-work-newlisp/</guid>
		<description><![CDATA[For the past few days have been spent trying to get the newLISP MySQL module to work with the 64-bit version of the libmysqlclient library. Here is what I did to get things working properly. Updating paths The file paths in the MySQL module only include the most common libmysqlclient paths. Update the files list [...]]]></description>
			<content:encoded><![CDATA[<p>For the past few days have been spent trying to get the newLISP MySQL module to work with the 64-bit version of the libmysqlclient library.  Here is what I did to get things working properly.<span id="more-16"></span></p>
<h4>Updating paths</h4>
<p>The file paths in the MySQL module only include the most common libmysqlclient paths.  Update the <code>files</code> list to contain <code>/usr/lib64</code> as well:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">set</span> 'files '<span style="color: #66cc66;">&#40;</span>
    <span style="color: #ff0000;">&quot;/usr/lib64/libmysqlclient.so&quot;</span> <span style="color: #808080; font-style: italic;">; 64 bit Linux, UNIX</span>
    <span style="color: #ff0000;">&quot;/usr/lib/libmysqlclient.so&quot;</span> <span style="color: #808080; font-style: italic;">; Linux, UNIX</span>
    <span style="color: #ff0000;">&quot;/usr/local/mysql/lib/libmysqlclient.dylib&quot;</span> <span style="color: #808080; font-style: italic;">; MacOS X</span>
<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>If you are not sure where you libmysqlclient library is, you can find it with this command (assuming it is somewhere in <code>/usr</code>):</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;">find /usr -<span style="color: #b1b100;">name</span> <span style="color: #ff0000;">&quot;libmysqlclient.so&quot;</span></pre></div></div>

<h4>Updating alignments</h4>
<p>The offsets for most structure fields are set at the beginning of mysql5.lsp.  They need to be updated:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>constant 'NUM_ROWS_OFFSET <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> big-endian <span style="color: #cc66cc;">4</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>constant 'NUM_FIELDS_OFFSET <span style="color: #cc66cc;">96</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>constant 'ERROR_OFFSET <span style="color: #cc66cc;">141</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>constant 'INSERT_ID_OFFSET <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> big-endian <span style="color: #cc66cc;">836</span> <span style="color: #cc66cc;">832</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>constant 'AFFECTED_ROWS_OFFSET <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> big-endian <span style="color: #cc66cc;">828</span> <span style="color: #cc66cc;">824</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>This is not necessarily the same on all systems.  In the newLISP source tree is a folder named util.  Compile sql.c and execute it to get the proper offsets.  Note that the numbers generated are only one of  the two used in this; you need to first determine the endianness of your system.  The module itself uses this newLISP form:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#40;</span>pack <span style="color: #ff0000;">&quot;&gt;ld&quot;</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>pack <span style="color: #ff0000;">&quot;ld&quot;</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>If that returns true, update the first number and offset the other number by -4.  Otherwise, update the second number and offset the first by 4 (except for <code>NUM_FIELDS_OFFSET</code> and <code>ERROR_OFFSET</code>).</p>
<p>The offsets for the MYSQL_FIELD structure fields are hard-coded in the functions <code>fetch-row</code> and <code>keep-type</code>.</p>
<p>In <code>keep-type</code>, update the line:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">set</span> 'data <span style="color: #66cc66;">&#40;</span>get-int <span style="color: #66cc66;">&#40;</span>int <span style="color: #66cc66;">&#40;</span>+ type_ptr <span style="color: #66cc66;">&#40;</span>* <span style="color: #cc66cc;">19</span> <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>&#8230;to:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">set</span> 'data <span style="color: #66cc66;">&#40;</span>get-int <span style="color: #66cc66;">&#40;</span>int <span style="color: #66cc66;">&#40;</span>+ type_ptr <span style="color: #66cc66;">&#40;</span>+ <span style="color: #66cc66;">&#40;</span>* <span style="color: #cc66cc;">9</span> <span style="color: #cc66cc;">8</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>* <span style="color: #cc66cc;">10</span> <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>That reflects that there are 9 8-byte fields (all char* or ulong) and 10 4-byte fields (all uint) in the MYSQL_FIELD struct.  That will keep the coerced types returned from queries straight.</p>
<p>Next, in <code>fetch-row</code>, the pointer to the field structure is found using:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">set</span> 'field_addr <span style="color: #66cc66;">&#40;</span>get-int <span style="color: #66cc66;">&#40;</span>int <span style="color: #66cc66;">&#40;</span>+ rdata <span style="color: #66cc66;">&#40;</span>* field <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Change the 4 to 8:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">set</span> 'field_addr <span style="color: #66cc66;">&#40;</span>get-int <span style="color: #66cc66;">&#40;</span>int <span style="color: #66cc66;">&#40;</span>+ rdata <span style="color: #66cc66;">&#40;</span>* field <span style="color: #cc66cc;">8</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>&#8230;or you will only get half the fields&#8217; values :).</p>
<h4>Data types</h4>
<p>On the newLISP forum, Lutz pointed out that in <code>fetch-row</code>, the call to <code>get-int</code> must be changed to <code>get-long</code> for the 64-bit library.  After a quick look at the types returned in the MySQL C api docs, I also updated <code>num-rows</code>, <code>affected-rows</code> and <code>inserted-id</code>.</p>
<h4>Test it out</h4>
<p>Load the updated module in the newLISP shell and run:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>test-mysql<span style="color: #66cc66;">&#41;</span></pre></div></div>

<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Submit article</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fmaking-64-bit-mysql-work-newlisp%2F&amp;title=Making+64-bit+MySQL+work+with+newLISP" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fmaking-64-bit-mysql-work-newlisp%2F&amp;title=Making+64-bit+MySQL+work+with+newLISP" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Making+64-bit+MySQL+work+with+newLISP&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fmaking-64-bit-mysql-work-newlisp%2F&amp;title=Making+64-bit+MySQL+work+with+newLISP" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fmaking-64-bit-mysql-work-newlisp%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fmaking-64-bit-mysql-work-newlisp%2F&amp;title=Making+64-bit+MySQL+work+with+newLISP" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fmaking-64-bit-mysql-work-newlisp%2F&amp;title=Making+64-bit+MySQL+work+with+newLISP" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fmaking-64-bit-mysql-work-newlisp%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Making+64-bit+MySQL+work+with+newLISP+@+http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fmaking-64-bit-mysql-work-newlisp%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.artfulcode.net/articles/making-64-bit-mysql-work-newlisp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL library for newLISP</title>
		<link>http://www.artfulcode.net/articles/sql-library-newlisp/</link>
		<comments>http://www.artfulcode.net/articles/sql-library-newlisp/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 21:24:35 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[foop]]></category>
		<category><![CDATA[functional]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[newlisp]]></category>
		<category><![CDATA[releases]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.artfulcode.net/articles/sql-library-newlisp/</guid>
		<description><![CDATA[The newLISP SQL library is a set of classes and functions to ease generation of SQL code in newLISP. The module is not yet feature-complete but is in a usable state. Much of the module uses the small convenience classes to &#8220;serialize&#8221; SQL expressions. Most of the module&#8217;s classes have :serialize methods that render the [...]]]></description>
			<content:encoded><![CDATA[<p>The newLISP SQL library is a set of classes and functions to ease generation of SQL code in newLISP.  The module is not yet feature-complete but is in a usable state.<span id="more-20"></span></p>
<p>Much of the module uses the small convenience classes to &#8220;serialize&#8221; SQL expressions.  Most of the module&#8217;s classes have <code>:serialize</code> methods that render the encapsulated data as a string.  For example, the <code>Field</code> class:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>f <span style="color: #66cc66;">&#40;</span>Field <span style="color: #ff0000;">&quot;table&quot;</span> <span style="color: #ff0000;">&quot;fieldname&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">serialize</span> f<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">=&amp;</span>gt<span style="color: #808080; font-style: italic;">; &quot;table.fieldname&quot;</span></pre></div></div>

<p>&#8230;or the <code>Condition</code> class:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>c <span style="color: #66cc66;">&#40;</span>Condition <span style="color: #ff0000;">&quot;&amp;gt;&quot;</span> <span style="color: #ff0000;">&quot;salary&quot;</span> <span style="color: #cc66cc;">65000</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">serialize</span> c<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">=&amp;</span>gt<span style="color: #808080; font-style: italic;">; &quot;salary &amp;gt; '65000'&quot;</span></pre></div></div>

<p>Note that values are enclosed in single quotes for ANSI compliance.  The most interesting function in the module, however, is <code>sql:expr</code>, which uses the <code>match</code>-based primitives in the <span style="text-decoration: line-through;">functional</span> module to generate various types of expressions:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> <span style="color: #ff0000;">&quot;employees&quot;</span> <span style="color: #ff0000;">&quot;first_name&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">=&amp;</span>gt<span style="color: #808080; font-style: italic;">; &quot;employees.first_name&quot;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> <span style="color: #ff0000;">&quot;LIKE&quot;</span> <span style="color: #ff0000;">&quot;first_name&quot;</span> <span style="color: #ff0000;">&quot;Stev%&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">=&amp;</span>gt<span style="color: #808080; font-style: italic;">; &quot;first_name LIKE 'Stev%'&quot;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> <span style="color: #ff0000;">&quot;OR&quot;</span> <span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> <span style="color: #ff0000;">&quot;LIKE&quot;</span> <span style="color: #ff0000;">&quot;first_name&quot;</span> <span style="color: #ff0000;">&quot;Stev%&quot;</span><span style="color: #66cc66;">&#41;</span>
               <span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> <span style="color: #ff0000;">&quot;LIKE&quot;</span> <span style="color: #ff0000;">&quot;last_name&quot;</span> <span style="color: #ff0000;">&quot;John%&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">=&amp;</span>gt<span style="color: #808080; font-style: italic;">; &quot;((first_name LIKE 'Stev%') OR (last_name LIKE 'John%'))&quot;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> <span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">=&amp;</span>gt<span style="color: #808080; font-style: italic;">;&quot;6&quot;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> 'myapp<span style="color: #66cc66;">:</span><span style="color: #555;">employees</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">=&amp;</span>gt<span style="color: #808080; font-style: italic;">; &quot;employees&quot;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> <span style="color: #ff0000;">&quot;CONV&quot;</span> <span style="color: #ff0000;">&quot;AF&quot;</span> <span style="color: #cc66cc;">16</span> <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">=&amp;</span>gt<span style="color: #808080; font-style: italic;">; &quot;CONV('AF',16,10)&quot;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> <span style="color: #ff0000;">&quot;LIKE&quot;</span> <span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> <span style="color: #ff0000;">&quot;employees&quot;</span> <span style="color: #ff0000;">&quot;first_name&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #ff0000;">&quot;Stev%&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">=&amp;</span>gt<span style="color: #808080; font-style: italic;">; &quot;employees.first_name LIKE 'Stev%'&quot;</span></pre></div></div>

<p>Additional functions directly express <code>select</code>, <code>update</code>, <code>insert</code>, and <code>delete</code> statements or handle data type conversions (such as parsing SQL datetimes).</p>
<h4>Functional</h4>
<p>Another addition to Artful Code&#8217;s module list is the <span style="text-decoration: line-through;">functional</span> module.  This library provides some basic conditionals that make use of <code>match</code> to process data.  These macros express program logic by associating blocks of code with the structure of data.</p>
<p>Here is an example using <code>match-case</code>. <code>match-case</code> accepts a single expression and a series of forms that describe what to do based on its structure.  Each case form consists of a <a href="http://www.newlisp.org/downloads/newlisp_manual.html#match">match expression</a>, a list of variables to be locally bound to the result of the match, and an individual form to evaluate in a local scope with the matched variables bound:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>x '<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span> <span style="color: #cc66cc;">2</span> <span style="color: #cc66cc;">3</span> <span style="color: #cc66cc;">4</span> <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>match-<span style="color: #b1b100;">case</span> x
        <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>? ? ?<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>a b c<span style="color: #66cc66;">&#41;</span>
         <span style="color: #66cc66;">&#40;</span>println <span style="color: #ff0000;">&quot;a b and c do not get bound here, because they do not match x&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>? ? ? *<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>a b c d<span style="color: #66cc66;">&#41;</span>
         <span style="color: #66cc66;">&#40;</span>println <span style="color: #ff0000;">&quot;a = 1, b = 2, c = 3, and d = '(4 5)&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Here, the second block would match because <code>(? ? ? *)</code> matches against <code>(1 2 3 4 5)</code> and creates the binding association, <code>((a 1) (b 2) (c 3) (d (4 5)))</code>.</p>
<p>Also included in the module is <code>match-cond</code>, which is more powerful than <code>match-case</code>. <code>match-cond</code> works like <code>cond</code>, except that instead of a user-defined conditional, the first form in each case is a list of <code>pattern</code>, <code>symbol-list</code>, and <code>target</code>.  See the <span style="text-decoration: line-through;">documentation</span> for more details.</p>
<p><strong>Edit (2009-02-16): the functional module in mentioned in this post has been replaced with the <a href="http://static.artfulcode.net/newlisp/matching.lsp.html">matching</a> module.</strong></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Submit article</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fsql-library-newlisp%2F&amp;title=SQL+library+for+newLISP" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fsql-library-newlisp%2F&amp;title=SQL+library+for+newLISP" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=SQL+library+for+newLISP&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fsql-library-newlisp%2F&amp;title=SQL+library+for+newLISP" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fsql-library-newlisp%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fsql-library-newlisp%2F&amp;title=SQL+library+for+newLISP" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fsql-library-newlisp%2F&amp;title=SQL+library+for+newLISP" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fsql-library-newlisp%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+SQL+library+for+newLISP+@+http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fsql-library-newlisp%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.artfulcode.net/articles/sql-library-newlisp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create/update function for CLSQL</title>
		<link>http://www.artfulcode.net/articles/create-update-function-clsql/</link>
		<comments>http://www.artfulcode.net/articles/create-update-function-clsql/#comments</comments>
		<pubDate>Fri, 09 May 2008 19:51:32 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[clsql]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.artfulcode.net/articles/create-update-function-clsql/</guid>
		<description><![CDATA[Django has a very handy model method in its database library called get_or_create, which either creates a new record using the keyword arguments passed as field values or gets a record using the arguments passed. from models import Person person = Person.objects.get_or_create&#40;first_name=&#34;John&#34;, last_name=&#34;Johnson&#34;&#41; It adds syntactic sugar to the common case of checking if an [...]]]></description>
			<content:encoded><![CDATA[<p>Django has a very handy model method in its database library called get_or_create, which either creates a new record using the keyword arguments passed as field values or gets a record using the arguments passed.<span id="more-25"></span></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> models <span style="color: #ff7700;font-weight:bold;">import</span> Person
person = Person.<span style="color: black;">objects</span>.<span style="color: black;">get_or_create</span><span style="color: black;">&#40;</span>first_name=<span style="color: #483d8b;">&quot;John&quot;</span>, last_name=<span style="color: #483d8b;">&quot;Johnson&quot;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>It adds syntactic sugar to the common case of checking if an entry exists, creating it if it does not, then updating (or creating with new) values.  The problem is that its <em>slow</em>.</p>
<p>I offload our most expensive database work on our server to a Lisp-based XML RPC server using <a href="http://clsql.b9.com/">CLSQL</a>.  I wrote an analog of get_or_create for CLSQL.  It does not have the advantage of Django&#8217;s keyword searches; all searches use <code>=</code> and pull the first row that matches the value.</p>
<p>The first function, <code>get-instance</code> is a helper to get a row in a view-class using a field/value pair.<br />
<code>create/update</code> takes the first three arguments and passes them to <code>get-instance</code> to get any existing match.</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> get-instance <span style="color: #66cc66;">&#40;</span>cls pk val<span style="color: #66cc66;">&#41;</span>
  #<span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#40;</span>clsql<span style="color: #66cc66;">:</span><span style="color: #555;">locally-enable-sql-reader-syntax</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>inst <span style="color: #66cc66;">&#40;</span>clsql<span style="color: #66cc66;">:</span><span style="color: #555;">select</span> cls <span style="color: #66cc66;">:</span><span style="color: #555;">flatp</span> t <span style="color: #66cc66;">:</span><span style="color: #555;">refresh</span> t <span style="color: #66cc66;">:</span><span style="color: #555;">limit</span> <span style="color: #cc66cc;">1</span>
                            <span style="color: #66cc66;">:</span><span style="color: #555;">where</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#40;</span>clsql<span style="color: #66cc66;">:</span><span style="color: #555;">sql-expression</span> <span style="color: #66cc66;">:</span><span style="color: #555;">attribute</span> pk<span style="color: #66cc66;">&#41;</span> val<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    #<span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#40;</span>clsql<span style="color: #66cc66;">:</span><span style="color: #555;">restore-sql-reader-syntax-state</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> inst <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> inst<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">nil</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> create/update <span style="color: #66cc66;">&#40;</span>cls pk val <span style="color: #66cc66;">&amp;</span>rest args<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>inst <span style="color: #66cc66;">&#40;</span>get-instance cls pk val<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> inst
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">apply</span> #'reinitialize-instance inst args<span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">apply</span> #'make-instance cls pk val args<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<h4>Usage:</h4>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>clsql<span style="color: #66cc66;">:</span><span style="color: #555;">def-view-class</span> person <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>id
        <span style="color: #66cc66;">:</span><span style="color: #555;">reader</span> person-id
        <span style="color: #66cc66;">:</span><span style="color: #555;">db-kind</span> <span style="color: #66cc66;">:</span><span style="color: #555;">key</span>
        <span style="color: #66cc66;">:</span><span style="color: #555;">db-constraints</span> <span style="color: #66cc66;">:</span><span style="color: #555;">not-</span><span style="color: #b1b100;">null</span>
        <span style="color: #66cc66;">:</span><span style="color: #555;">type</span> <span style="color: #b1b100;">integer</span>
        <span style="color: #66cc66;">:</span><span style="color: #555;">initarg</span> <span style="color: #66cc66;">:</span><span style="color: #555;">id</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>last-<span style="color: #b1b100;">name</span>
        <span style="color: #66cc66;">:</span><span style="color: #555;">accessor</span> person-last-<span style="color: #b1b100;">name</span>
        <span style="color: #66cc66;">:</span><span style="color: #555;">db-constraints</span> <span style="color: #66cc66;">:</span><span style="color: #555;">not-</span><span style="color: #b1b100;">null</span>
        <span style="color: #66cc66;">:</span><span style="color: #555;">type</span> <span style="color: #66cc66;">&#40;</span>clsql<span style="color: #66cc66;">:</span><span style="color: #555;">varchar</span> <span style="color: #cc66cc;">25</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">:</span><span style="color: #555;">initarg</span> <span style="color: #66cc66;">:</span><span style="color: #555;">last-</span><span style="color: #b1b100;">name</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>first-<span style="color: #b1b100;">name</span>
        <span style="color: #66cc66;">:</span><span style="color: #555;">accessor</span> person-first-<span style="color: #b1b100;">name</span>
        <span style="color: #66cc66;">:</span><span style="color: #555;">db-constraints</span> <span style="color: #66cc66;">:</span><span style="color: #555;">not-</span><span style="color: #b1b100;">null</span>
        <span style="color: #66cc66;">:</span><span style="color: #555;">type</span> <span style="color: #66cc66;">&#40;</span>clsql<span style="color: #66cc66;">:</span><span style="color: #555;">varchar</span> <span style="color: #cc66cc;">25</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">:</span><span style="color: #555;">initarg</span> <span style="color: #66cc66;">:</span><span style="color: #555;">first-</span><span style="color: #b1b100;">name</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>defvar john <span style="color: #66cc66;">&#40;</span>create/update 'person <span style="color: #66cc66;">:</span><span style="color: #555;">id</span> <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>If there is row with id 3 in the database, it will grab that (or, if the key is not unique, it will grab the first matching row.)  If there is no entry with that id, it will create a new one, that can then be updated the normal way:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">setf</span> <span style="color: #66cc66;">&#40;</span>person-last-<span style="color: #b1b100;">name</span> john<span style="color: #66cc66;">&#41;</span> <span style="color: #ff0000;">&quot;John&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">setf</span> <span style="color: #66cc66;">&#40;</span>person-first-<span style="color: #b1b100;">name</span> john<span style="color: #66cc66;">&#41;</span> <span style="color: #ff0000;">&quot;Johnson&quot;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>The other alternative is to get and set all in one go:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>defvar john <span style="color: #66cc66;">&#40;</span>create/update 'person
                            <span style="color: #66cc66;">:</span><span style="color: #555;">id</span> <span style="color: #cc66cc;">3</span>
                            <span style="color: #66cc66;">:</span><span style="color: #555;">last-</span><span style="color: #b1b100;">name</span> <span style="color: #ff0000;">&quot;Johnson&quot;</span>
                            <span style="color: #66cc66;">:</span><span style="color: #555;">first-</span><span style="color: #b1b100;">name</span> <span style="color: #ff0000;">&quot;John&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>It&#8217;s pretty simple but it is very useful.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Submit article</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fcreate-update-function-clsql%2F&amp;title=Create%2Fupdate+function+for+CLSQL" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fcreate-update-function-clsql%2F&amp;title=Create%2Fupdate+function+for+CLSQL" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Create%2Fupdate+function+for+CLSQL&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fcreate-update-function-clsql%2F&amp;title=Create%2Fupdate+function+for+CLSQL" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fcreate-update-function-clsql%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fcreate-update-function-clsql%2F&amp;title=Create%2Fupdate+function+for+CLSQL" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fcreate-update-function-clsql%2F&amp;title=Create%2Fupdate+function+for+CLSQL" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fcreate-update-function-clsql%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Create%2Fupdate+function+for+CLSQL+@+http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fcreate-update-function-clsql%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.artfulcode.net/articles/create-update-function-clsql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

