<?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>Jigsaw Boys &#187; SQL</title>
	<atom:link href="http://www.jigsawboys.com/category/development/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jigsawboys.com</link>
	<description>Security, Network and Computer Tech Tip Database!</description>
	<lastBuildDate>Mon, 10 May 2010 02:07:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Selecting where row value is null</title>
		<link>http://www.jigsawboys.com/2006/12/08/selecting-where-row-value-is-null/</link>
		<comments>http://www.jigsawboys.com/2006/12/08/selecting-where-row-value-is-null/#comments</comments>
		<pubDate>Fri, 08 Dec 2006 00:28:23 +0000</pubDate>
		<dc:creator>Jamsi</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.jigsawboys.com/2006/12/08/selecting-where-row-value-is-null/</guid>
		<description><![CDATA[Don&#8217;t ask me why, but I ALWAYS forget how to select results from an mSQL database where the value is null. It&#8217;s just weird. I always try select * from table where colname = null or select * from table where colname = &#8221; But the correct way is to select using IS NULL! select [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t ask me why, but I ALWAYS forget how to select results from an mSQL database where the value is null. It&#8217;s just weird.</p>
<p>I always try</p>
<p><strong>select * from table where colname = null </strong><br />
or<br />
<strong>select * from table where colname = &#8221;</strong></p>
<p>But the correct way is to select using IS NULL!</p>
<p><strong>select * from table where colname IS NULL</strong></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.jigsawboys.com/2006/12/08/selecting-where-row-value-is-null/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL error #1135: Can&#8217;t create a new thread (errno 11).</title>
		<link>http://www.jigsawboys.com/2006/04/13/mysql-error-1135-cant-create-a-new-thread-errno-11/</link>
		<comments>http://www.jigsawboys.com/2006/04/13/mysql-error-1135-cant-create-a-new-thread-errno-11/#comments</comments>
		<pubDate>Thu, 13 Apr 2006 06:12:10 +0000</pubDate>
		<dc:creator>Jonesy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[1135]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.jigsawboys.com/2006/04/13/mysql-error-1135-cant-create-a-new-thread-errno-11/</guid>
		<description><![CDATA[This error was the bane of my life for a while, and it was very hard to get a definitive answer as to what was causing it, I hope this saves you some trouble. My website occasionally got large traffic spikes, and at the top of these peaks, I would start to see errors like [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>This error was the bane of my life for a while, and it was very hard to get a definitive answer as to what was causing it, I hope this saves you some trouble.</p>
<p>My website occasionally got large traffic spikes, and at the top of these peaks, I would start to see errors like these:</p>
<div class="code">MySQL error #1135: Can&#8217;t create a new thread (errno 11). If you are not out of available memory, you can consult the manual for a possible OS-dependent bug.</div>
<p>I looked in the my.cnf file on the db server and looked at the open files limit, because a process is counted as an open file, but it seemed fine:</p>
<div class="code"><strong>[mysqld_safe]</strong><br />
<strong> open-files-limit=10240</strong></div>
<p>I also checked that maximum connections was high enough, it was at 2048.</p>
<p>What the open-files-limit in my.cnf files does is it tells the init script to use ulimit to whatever number you put in there.</p>
<p>After a lot of digging around various places, and much frustration, I discovered that by default linux has a hard limit of 1024 open files for all non super-users, so even though I had set a high open-files-limit, it was capped at 1024 by the OS. I also discovered how to raise it;</p>
<div class="code"><strong>/etc/security/limits.conf</strong></div>
<p>This file is used by PAM to set things like maximum processes, max open files, memory usage etc and these limits can be set on a per-user basis, so I added these lines:</p>
<div class="code"><strong> mysql        soft    nofile           4096</strong><br />
<strong> mysql        hard    nofile           4096</strong></div>
<p><strong> </strong><br />
and restarted MySQL. BAM! That did the trick.<br />
One more thing to make sure of is that the su pam config file (/etc/pam.d/su) is using pam_limits.so, as that is the pam module which enforces limits.</p>
<p>Good luck!<br />
-Jonesy</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.jigsawboys.com/2006/04/13/mysql-error-1135-cant-create-a-new-thread-errno-11/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Download counter (Stored Procedure)</title>
		<link>http://www.jigsawboys.com/2006/01/17/download-counter-stored-procedure/</link>
		<comments>http://www.jigsawboys.com/2006/01/17/download-counter-stored-procedure/#comments</comments>
		<pubDate>Mon, 16 Jan 2006 23:29:08 +0000</pubDate>
		<dc:creator>Jamsi</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.jigsawboys.com/?p=24</guid>
		<description><![CDATA[A stored procedure I used as a download script. You pass this procedure a parameter (filename), it checks the database if a record for this exists. If so it increments the record by one. If the record doesnt exist it creates it for you. For this to work I used a table with two columns. [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>A stored procedure I used as a download script. You pass this procedure a parameter (filename), it checks the database if a record for this exists. If so it increments the record by one. If the record doesnt exist it creates it for you.</p>
<p>For this to work I used a table with two columns.</p>
<p>filename varchar(255)<br />
hits numeric (9)</p>
<pre class="code"><code>
IF EXISTS (
	SELECT name FROM dbo.sysobjects
	WHERE name = 'updateStats'
	AND type = 'P'
	)DROP PROCEDURE dbo.[updateStats]
GO
	CREATE PROCEDURE updateStats
	(
		@filename varchar(25)
	)
AS
IF EXISTS(SELECT 'filename' FROM kav_dlstats WHERE filename = @filename)
BEGIN
	--If it exists, update the record!
	UPDATE kav_dlstats SET hits=hits+1 WHERE filename = @filename
END
ELSE
	BEGIN
	--Else lets make a new record
	INSERT into kav_dlstats(filename, hits) VALUES(@filename, '1')
END
</code></pre>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.jigsawboys.com/2006/01/17/download-counter-stored-procedure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
