<?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>EdgardKSB</title>
	<atom:link href="http://edgardksb.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://edgardksb.com</link>
	<description>A simple code writer</description>
	<lastBuildDate>Sat, 03 Sep 2011 19:09:47 +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>TIdMessage.LoadFromFile error message &#8220;Read Timeout&#8221;</title>
		<link>http://edgardksb.com/delphi/tidmessage-loadfromfile-error-message-read-timeout/</link>
		<comments>http://edgardksb.com/delphi/tidmessage-loadfromfile-error-message-read-timeout/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 19:06:35 +0000</pubDate>
		<dc:creator>edgardksb</dc:creator>
				<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://edgardksb.com/?p=156</guid>
		<description><![CDATA[Hi.
This error occurs when your message does not has the terminator of message.
Use &#8220;.&#8221; terminator.
For working doing this:
var
  slMail : TStringList;
  mMsg : TIdMessage;
begin
  slMail      := TStringList.Create;
  //slMail.Text := STRING OF THE YOUR EMAIL MESSAGE
  slMail.Add('.');
  slMail.SaveToFile(sFileName);

  mMsg := TIdMessage.Create(nil);
  mMsg.LoadFromFile(sFileName);
end;
]]></description>
			<content:encoded><![CDATA[<p>Hi.</p>
<p>This error occurs when your message does not has the terminator of message.<br />
Use &#8220;.&#8221; terminator.</p>
<p>For working doing this:</p>
<pre class="brush:delphi">var
  slMail : TStringList;
  mMsg : TIdMessage;
begin
  slMail      := TStringList.Create;
  //slMail.Text := STRING OF THE YOUR EMAIL MESSAGE
  slMail.Add('.');
  slMail.SaveToFile(sFileName);

  mMsg := TIdMessage.Create(nil);
  mMsg.LoadFromFile(sFileName);
end;</pre>
]]></content:encoded>
			<wfw:commentRss>http://edgardksb.com/delphi/tidmessage-loadfromfile-error-message-read-timeout/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Problemas Acentuação Tomcat</title>
		<link>http://edgardksb.com/linux/problemas-acentuacao-tomcat/</link>
		<comments>http://edgardksb.com/linux/problemas-acentuacao-tomcat/#comments</comments>
		<pubDate>Tue, 17 May 2011 12:27:14 +0000</pubDate>
		<dc:creator>edgardksb</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://edgardksb.com/?p=149</guid>
		<description><![CDATA[Bom dia.
Este post vai em português somente serve para os brasileiros.
Se você alguma vez desenvolveu algo no Tomcat no Windows em Português teve problema com acentuação ao colocar em produção em um servidor Linux em Inglês.
Todas as acentuações saem com &#8220;?&#8221;.
Para resolver para basta você setar duas variáveis de ambiente no Linux antes de iniciar [...]]]></description>
			<content:encoded><![CDATA[<p>Bom dia.</p>
<p>Este post vai em português somente serve para os brasileiros.<br />
Se você alguma vez desenvolveu algo no Tomcat no Windows em Português teve problema com acentuação ao colocar em produção em um servidor Linux em Inglês.</p>
<p>Todas as acentuações saem com &#8220;?&#8221;.</p>
<p>Para resolver para basta você setar duas variáveis de ambiente no Linux antes de iniciar o tomcat.</p>
<pre class="brush:shell">
export LC_ALL=pt_BR
export LANG=pt_BR
</pre>
<p>Até mais, sucesso.</p>
]]></content:encoded>
			<wfw:commentRss>http://edgardksb.com/linux/problemas-acentuacao-tomcat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>pg_unescape_bytea Doesn&#8217;t work using PostgreSQL 9.0</title>
		<link>http://edgardksb.com/databases/postgresql/pg_unescape_bytea-doesnt-work-using-postgresql-9-0/</link>
		<comments>http://edgardksb.com/databases/postgresql/pg_unescape_bytea-doesnt-work-using-postgresql-9-0/#comments</comments>
		<pubDate>Tue, 17 May 2011 12:16:23 +0000</pubDate>
		<dc:creator>edgardksb</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[PostgreSQL]]></category>

		<guid isPermaLink="false">http://edgardksb.com/?p=143</guid>
		<description><![CDATA[Hi..
If you use PHP and using pg_unescape_bytea function using the new version of PostgreSQL you have the surprise. The function don&#8217;t return your files.
PostgreSQL 9.0 introduced &#8220;hex&#8221; as the new default format for encoding binary data. Because &#8220;pg_unescape_bytea&#8221; only works with the old &#8220;escape&#8221; format.
Solution is simple:

Setting your database for bytea output in escape format.
ALTER [...]]]></description>
			<content:encoded><![CDATA[<p>Hi..</p>
<p>If you use PHP and using pg_unescape_bytea function using the new version of PostgreSQL you have the surprise. The function don&#8217;t return your files.</p>
<p>PostgreSQL 9.0 introduced &#8220;hex&#8221; as the new default format for encoding binary data. Because &#8220;pg_unescape_bytea&#8221; only works with the old &#8220;escape&#8221; format.</p>
<p>Solution is simple:</p>
<ul>
<li>Setting your database for bytea output in escape format.
<pre class="brush:sql">ALTER DATABASE your_database SET bytea_output = 'escape';</pre>
</li>
<li>
Or setting users for bytea output in escape format.</p>
<pre class="brush:sql">ALTER ROLE your_user SET bytea_output = 'escape';</pre>
</li>
</ul>
<p>Works!!..</p>
<p>Bye.</p>
]]></content:encoded>
			<wfw:commentRss>http://edgardksb.com/databases/postgresql/pg_unescape_bytea-doesnt-work-using-postgresql-9-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove &#8220;.svn&#8221;, recursive</title>
		<link>http://edgardksb.com/linux/remove-svn-recursive/</link>
		<comments>http://edgardksb.com/linux/remove-svn-recursive/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 12:53:38 +0000</pubDate>
		<dc:creator>edgardksb</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://edgardksb.com/?p=137</guid>
		<description><![CDATA[Hi,
This command remove all &#8220;.svn&#8221; folder&#8217;s and files recursive in your directory.
Enter in folder with you want remove and:

find ./ -name ".svn" &#124; xargs rm -Rf

See..
]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>This command remove all &#8220;.svn&#8221; folder&#8217;s and files recursive in your directory.<br />
Enter in folder with you want remove and:</p>
<pre class="brush:shell">
find ./ -name ".svn" | xargs rm -Rf
</pre>
<p>See..</p>
]]></content:encoded>
			<wfw:commentRss>http://edgardksb.com/linux/remove-svn-recursive/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using SSL in Lighttpd</title>
		<link>http://edgardksb.com/webserver/using-ssl-in-lighttpd/</link>
		<comments>http://edgardksb.com/webserver/using-ssl-in-lighttpd/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 15:24:44 +0000</pubDate>
		<dc:creator>edgardksb</dc:creator>
				<category><![CDATA[Lighttpd]]></category>
		<category><![CDATA[Web Server]]></category>

		<guid isPermaLink="false">http://edgardksb.com/?p=131</guid>
		<description><![CDATA[Hi.
For use SSL in Lighttpd, you first need create the .pem file.
The .pem file is the .key file and the .crt file, together.
For create you can use this command on your terminal.
cat ssl.key ssl.crt > ssl.pem
Now you need config the Lighttpd for use SSL in lighttpd.conf.

$SERVER["socket"] == "your_ip_address:443" {
    ssl.engine  = [...]]]></description>
			<content:encoded><![CDATA[<p>Hi.</p>
<p>For use SSL in Lighttpd, you first need create the <strong>.pem</strong> file.<br />
The <strong>.pem</strong> file is the <strong>.key</strong> file and the <strong>.crt</strong> file, together.<br />
For create you can use this command on your terminal.</p>
<pre class="brush:shell">cat ssl.key ssl.crt > ssl.pem</pre>
<p>Now you need config the Lighttpd for use SSL in <strong>lighttpd.conf</strong>.</p>
<pre class="brush:plain">
$SERVER["socket"] == "your_ip_address:443" {
    ssl.engine  = "enable"
    ssl.ca-file   = "/your_path/ca.txt"
    ssl.pemfile = "/your_path/ssl.pem"
}
</pre>
<p>Restart you server, and done&#8230;</p>
<p>See you&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://edgardksb.com/webserver/using-ssl-in-lighttpd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lighttpd + Alias + ReWrite (Together)</title>
		<link>http://edgardksb.com/webserver/lighttpd-alias-rewrite-together/</link>
		<comments>http://edgardksb.com/webserver/lighttpd-alias-rewrite-together/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 15:11:28 +0000</pubDate>
		<dc:creator>edgardksb</dc:creator>
				<category><![CDATA[Lighttpd]]></category>
		<category><![CDATA[Web Server]]></category>

		<guid isPermaLink="false">http://edgardksb.com/?p=128</guid>
		<description><![CDATA[Hi.
In my case i needed use alias and rewrite together.
My problem is ever Lighttpd call rewrite, and ignore the alias rules.
My solution for that is (In my case), in lighttpd.conf:
alias.url = (
	"/alias1"    => "/var/www/alias1",
	"/alias2"    => "/var/www/alias2"
)

url.rewrite-once = (
	"^/([a-z][^(alias1&#124;alias2)][^\.*]*)$"=>	"index.php?path=$1"
)
Where in the regular expression used in rewrite rule, verify if the [...]]]></description>
			<content:encoded><![CDATA[<p>Hi.</p>
<p>In my case i needed use alias and rewrite together.<br />
My problem is ever Lighttpd call rewrite, and ignore the alias rules.</p>
<p>My solution for that is (In my case), in <strong>lighttpd.conf</strong>:</p>
<pre class="brush:plain">alias.url = (
	"/alias1"    => "/var/www/alias1",
	"/alias2"    => "/var/www/alias2"
)

url.rewrite-once = (
	"^/([a-z][^(alias1|alias2)][^\.*]*)$"=>	"index.php?path=$1"
)</pre>
<p>Where in the regular expression used in rewrite rule, verify if the url don&#8217;t use alias1 or alias2.</p>
<p>For me worked.</p>
]]></content:encoded>
			<wfw:commentRss>http://edgardksb.com/webserver/lighttpd-alias-rewrite-together/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Permalinks in WordPress on Lighttpd</title>
		<link>http://edgardksb.com/webserver/permalinks-in-wordpress-on-lighttpd/</link>
		<comments>http://edgardksb.com/webserver/permalinks-in-wordpress-on-lighttpd/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 14:57:24 +0000</pubDate>
		<dc:creator>edgardksb</dc:creator>
				<category><![CDATA[Lighttpd]]></category>
		<category><![CDATA[Web Server]]></category>

		<guid isPermaLink="false">http://edgardksb.com/?p=126</guid>
		<description><![CDATA[Hi.
Recently i changed my webserver of Apache to Lighttpd.
And has some problems for migrate ReWrite of Apache to Lighttpd;
For solution Rewrite need in permalink the WordPress, you need these line in your lighttpd.conf
url.rewrite = (
	"^/(wp-.+).*/?" =&#62; "$0",
	"^/(sitemap.xml)" =&#62; "$0",
	"^/(xmlrpc.php)" =&#62; "$0",
	"^/(.+)/?$" =&#62; "/index.php/$1"
)
]]></description>
			<content:encoded><![CDATA[<p>Hi.</p>
<p>Recently i changed my webserver of Apache to Lighttpd.<br />
And has some problems for migrate ReWrite of Apache to Lighttpd;</p>
<p>For solution Rewrite need in permalink the WordPress, you need these line in your <strong>lighttpd.conf</strong></p>
<pre class="brush:plain">url.rewrite = (
	"^/(wp-.+).*/?" =&gt; "$0",
	"^/(sitemap.xml)" =&gt; "$0",
	"^/(xmlrpc.php)" =&gt; "$0",
	"^/(.+)/?$" =&gt; "/index.php/$1"
)</pre>
]]></content:encoded>
			<wfw:commentRss>http://edgardksb.com/webserver/permalinks-in-wordpress-on-lighttpd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Lighttpd + PHP on Ubuntu</title>
		<link>http://edgardksb.com/linux/installing-lighttpd-php-on-ubuntu/</link>
		<comments>http://edgardksb.com/linux/installing-lighttpd-php-on-ubuntu/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 23:10:34 +0000</pubDate>
		<dc:creator>edgardksb</dc:creator>
				<category><![CDATA[Lighttpd]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://edgardksb.com/?p=123</guid>
		<description><![CDATA[Hi..
Today i going to show for you how install Lighttpd using Php on ubuntu.
Is very simple because lighttpd has on Ubuntu packages.
sudo apt-get install lighttpd php5-cgi
After install enable fastcgi module in Lighttpd.
sudo lighty-enable-mod fastcgi
Done!!!, your lighttpd is now runnig.
Open you browser in http://localhost
If you use mysql with php:
sudo apt-get install php5-mysql
Or if you use Postgresql [...]]]></description>
			<content:encoded><![CDATA[<p>Hi..</p>
<p>Today i going to show for you how install Lighttpd using Php on ubuntu.<br />
Is very simple because lighttpd has on Ubuntu packages.</p>
<pre class="brush:shell">sudo apt-get install lighttpd php5-cgi</pre>
<p>After install enable fastcgi module in Lighttpd.</p>
<pre class="brush:shell">sudo lighty-enable-mod fastcgi</pre>
<p>Done!!!, your lighttpd is now runnig.<br />
Open you browser in <strong>http://localhost</strong></p>
<p>If you use mysql with php:</p>
<pre class="brush:shell">sudo apt-get install php5-mysql</pre>
<p>Or if you use Postgresql with php:</p>
<pre class="brush:shell">sudo apt-get install php5-pgsql</pre>
<p>The lighttpd configuration is <strong>/etc/lighttpd/lighttpd.conf</strong>, and the PHP config file is <strong>/etc/php5/cgi/php5.ini</strong>.</p>
<p>For default the document root of lighttpd is <strong>/var/www</strong>.</p>
<p>Works very well, for me lighttpd is more fast than apache.</p>
<p>Bye.</p>
]]></content:encoded>
			<wfw:commentRss>http://edgardksb.com/linux/installing-lighttpd-php-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Take picture with your Webcam using Flash</title>
		<link>http://edgardksb.com/javascript/take-picture-with-your-webcam-using-flash/</link>
		<comments>http://edgardksb.com/javascript/take-picture-with-your-webcam-using-flash/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 14:39:42 +0000</pubDate>
		<dc:creator>edgardksb</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://edgardksb.com/?p=91</guid>
		<description><![CDATA[Hi&#8230;
Recently i needed take pictures using webcam in my web software, for one store.
My software is developed in PHP, and i used flash for take the picture.
The swf you can download here.
For use that swf, i created some params in Javascript.
You can use that:
Add div in your html:



And add Javascript command:
var mainswf = new SWFObject("picture.swf", [...]]]></description>
			<content:encoded><![CDATA[<p>Hi&#8230;</p>
<p>Recently i needed take pictures using webcam in my web software, for one store.<br />
My software is developed in PHP, and i used flash for take the picture.<br />
The <strong>swf</strong> you can download <a href="http://edgardksb.com/download/flash/picture.swf">here</a>.</p>
<p>For use that <strong>swf</strong>, i created some params in Javascript.</p>
<p>You can use that:<br />
Add div in your html:</p>
<pre class="brush:html">
<div id='flashArea'></div>
</pre>
<p>And add Javascript command:</p>
<pre class="brush:js">var mainswf = new SWFObject("picture.swf", "main", "640", "480", "9");
mainswf.addVariable("sSaveUrl", "yourServerSide.php");
mainswf.addVariable("iJpegQuality", 50);
mainswf.write("flashArea");</pre>
<p>I used <strong>swfobject</strong>, you can seen <a href="http://code.google.com/p/swfobject/">here</a>.</p>
<p>In variable <strong>sSaveUrl</strong> you pass the url for saving you image.<br />
You can use PHP, ASP, CGI, &#8230;.</p>
<p>The variable <strong>iJpegQuality</strong> you pass in range of 0 for 100, the JPEG quality.</p>
<p>Now you need take the picture, right ?</p>
<p>Use that javascript command:</p>
<pre class="brush:js">document.getElementById("main").startCapture();</pre>
<p>The actionscript take the picture and send for your url.</p>
<p>If you use php, you can use that (Very simple sample):</p>
<pre class="brush:php">if(isset($GLOBALS["HTTP_RAW_POST_DATA"])){
	$jpg = $GLOBALS["HTTP_RAW_POST_DATA"];
	file_put_contents("/images/save/image.jpg", $jpg);
}</pre>
<p>Work for me. If you need the <strong>fla</strong>, send me e-mail, <strong>to@edgardksb.com</strong>.</p>
<p>Bye.</p>
]]></content:encoded>
			<wfw:commentRss>http://edgardksb.com/javascript/take-picture-with-your-webcam-using-flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Audit Log in PostgreSQL in Ubuntu</title>
		<link>http://edgardksb.com/databases/installing-audit-log-in-postgresql-in-ubuntu/</link>
		<comments>http://edgardksb.com/databases/installing-audit-log-in-postgresql-in-ubuntu/#comments</comments>
		<pubDate>Sun, 30 Aug 2009 17:49:52 +0000</pubDate>
		<dc:creator>edgardksb</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[PostgreSQL]]></category>

		<guid isPermaLink="false">http://edgardksb.com/?p=84</guid>
		<description><![CDATA[Hi.
Today i explain how install audit log in PostgreSQL in Ubuntu.
Audit log, is the trigger&#8217;s function&#8217;s and one lib in C, with create table log&#8217;s of all update&#8217;s in table&#8217;s with audit enabled.
I recomend you create one schema where will created the log table&#8217;s.
Now we will install.
First, download the audit log in http://pgfoundry.org/projects/tablelog/.
In my case [...]]]></description>
			<content:encoded><![CDATA[<p>Hi.<br />
Today i explain how install audit log in PostgreSQL in Ubuntu.<br />
Audit log, is the trigger&#8217;s function&#8217;s and one lib in C, with create table log&#8217;s of all update&#8217;s in table&#8217;s with audit enabled.<br />
I recomend you create one schema where will created the log table&#8217;s.<br />
Now we will install.</p>
<p>First, download the audit log in <a href="http://pgfoundry.org/projects/tablelog/">http://pgfoundry.org/projects/tablelog/</a>.<br />
In my case i have PostgreSQL installed with Synapctics.<br />
You need to, the PostgreSQL dev librarys and the <strong>pg_config</strong> installed.</p>
<p>Case you need install use this commands:</p>
<pre class="brush:shell">sudo apt-get install postgresql-server-dev-8.3
sudo apt-get install libpq-dev</pre>
<p>Now extract files of the audit log, and compiling and install the librarys.</p>
<pre class="brush:shell">sudo make USE_PGXS=1
sudo make USE_PGXS=1 install</pre>
<p>Run the this SQL script&#8217;s:</p>
<pre class="brush:sql">CREATE FUNCTION "table_log" ()
RETURNS trigger
AS '$libdir/table_log', 'table_log' LANGUAGE 'C';
CREATE FUNCTION "table_log_restore_table" (VARCHAR, VARCHAR, CHAR, CHAR, CHAR, TIMESTAMPTZ, CHAR, INT, INT)
RETURNS VARCHAR
AS '$libdir/table_log', 'table_log_restore_table' LANGUAGE 'C';

CREATE FUNCTION "table_log_restore_table" (VARCHAR, VARCHAR, CHAR, CHAR, CHAR, TIMESTAMPTZ, CHAR, INT)
RETURNS VARCHAR
AS '$libdir/table_log', 'table_log_restore_table' LANGUAGE 'C';

CREATE FUNCTION "table_log_restore_table" (VARCHAR, VARCHAR, CHAR, CHAR, CHAR, TIMESTAMPTZ, CHAR)
RETURNS VARCHAR
AS '$libdir/table_log', 'table_log_restore_table' LANGUAGE 'C';

CREATE FUNCTION "table_log_restore_table" (VARCHAR, VARCHAR, CHAR, CHAR, CHAR, TIMESTAMPTZ)
RETURNS VARCHAR
AS '$libdir/table_log', 'table_log_restore_table' LANGUAGE 'C';</pre>
<p>SQL Script&#8217;s for create trigger function&#8217;s:</p>
<pre class="brush:sql">CREATE OR REPLACE FUNCTION table_log_init(int, text, text, text, text) RETURNS void AS '
DECLARE
	level        ALIAS FOR $1;
	orig_schema  ALIAS FOR $2;
	orig_name    ALIAS FOR $3;
	log_schema   ALIAS FOR $4;
	log_name     ALIAS FOR $5;
	do_log_user  int = 0;
	level_create text = '''';
	orig_qq      text;
	log_qq       text;
BEGIN
	-- Quoted qualified names
	orig_qq := quote_ident(orig_schema)||''.''||quote_ident(orig_name);
	log_qq := quote_ident(log_schema)||''.''||quote_ident(log_name);

	IF level &lt;&gt; 3 THEN
		level_create := level_create
		||'', trigger_id BIGSERIAL NOT NULL PRIMARY KEY'';

		IF level &lt;&gt; 4 THEN
			level_create := level_create
			||'', trigger_user VARCHAR(32) NOT NULL'';
			do_log_user := 1;

			IF level &lt;&gt; 5 THEN
				RAISE EXCEPTION ''table_log_init: First arg has to be 3, 4 or 5.'';
			END IF;
		END IF;
	END IF;

	EXECUTE ''CREATE TABLE ''||log_qq
		||''(LIKE ''||orig_qq
		||'', trigger_mode VARCHAR(10) NOT NULL''
		||'', trigger_tuple VARCHAR(5) NOT NULL''
		||'', trigger_changed TIMESTAMPTZ NOT NULL''
		||level_create
		||'')'';

	EXECUTE ''CREATE TRIGGER "table_log_trigger" AFTER UPDATE OR INSERT OR DELETE ON ''
		||orig_qq||'' FOR EACH ROW EXECUTE PROCEDURE table_log(''
		||quote_literal(log_name)||'',''
		||do_log_user||'',''
		||quote_literal(log_schema)||'')'';

	RETURN;
END;
' LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION table_log_init(int, text) RETURNS void AS '
DECLARE
	level        ALIAS FOR $1;
	orig_name    ALIAS FOR $2;
BEGIN
	PERFORM table_log_init(level, orig_name, current_schema());
	RETURN;
END;
' LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION table_log_init(int, text, text) RETURNS void AS '
DECLARE
	level        ALIAS FOR $1;
	orig_name    ALIAS FOR $2;
	log_schema   ALIAS FOR $3;
BEGIN
	PERFORM table_log_init(level, current_schema(), orig_name, log_schema);
	RETURN;
END;
' LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION table_log_init(int, text, text, text) RETURNS void AS '
DECLARE
	level        ALIAS FOR $1;
	orig_schema  ALIAS FOR $2;
	orig_name    ALIAS FOR $3;
	log_schema   ALIAS FOR $4;
BEGIN
	PERFORM table_log_init(level, orig_schema, orig_name, log_schema,
	CASE WHEN orig_schema=log_schema
		THEN orig_name||''_log'' ELSE orig_name END);
	RETURN;
END;
' LANGUAGE plpgsql;</pre>
<p>In files of the Audit log have the file table_log_init.sql with the SQL script&#8217;s.</p>
<p>Now for you enable the audit log, is simple. Just:</p>
<pre class="brush:sql">table_log_init(5, 'TABLE_NAME', 'LOG')</pre>
<p>The commands for enabled audit log:</p>
<pre class="brush:sql">/* create the log table as tablename_log */
table_log_init(ncols, tablename):

/* create the log table with the same name as the original table,
   but in the schema logschema. */
table_log_init(ncols, tablename, logschema):

/* log the changes in table tableschema.tablename into the log table
   logschema.logname. */
table_log_init(ncols, tableschema, tablename, logschema, logname):</pre>
<p>Bye.</p>
]]></content:encoded>
			<wfw:commentRss>http://edgardksb.com/databases/installing-audit-log-in-postgresql-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

