<?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>Applied dimensionality &#187; coding</title>
	<atom:link href="http://ykud.com/blog/category/coding/feed" rel="self" type="application/rss+xml" />
	<link>http://ykud.com/blog</link>
	<description></description>
	<lastBuildDate>Mon, 19 Jul 2010 07:48:45 +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>Closed cube lattice drawer</title>
		<link>http://ykud.com/blog/coding/closed-cube-lattice-drawer</link>
		<comments>http://ykud.com/blog/coding/closed-cube-lattice-drawer#comments</comments>
		<pubDate>Fri, 30 May 2008 20:34:23 +0000</pubDate>
		<dc:creator>ykud</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[closed_cubes]]></category>
		<category><![CDATA[olap]]></category>

		<guid isPermaLink="false">http://ykud.com/blog/?p=140</guid>
		<description><![CDATA[I've made this simple web-based closed cube drawing tool to explain what closed cubes are and how they're good in removing redundant aggregates from storage. I've wrote this for myself initially to get better insights on different aggregate situations and thought somebody might get interested as well. Go check it out, if you're interested in [...]]]></description>
			<content:encoded><![CDATA[<div>I've made this simple web-based closed cube drawing tool to explain what closed cubes are and how they're good in removing redundant aggregates from storage. I've wrote this for myself initially to get better insights on different aggregate situations and thought somebody might get interested as well.<br />
<a href="http://ykud.com/draw_closed_cube">Go check it out</a>, if you're interested in how future olap engines will be working )))</p>
<p>Look how bad it is with all dense cubes, like (copy-paste these values)<br />
R2;spring<br />
R2;autumn<br />
R1;spring<br />
R1;autumn</p>
<p>and how good with more or less sparse ones</p>
<p>R2;spring;store1<br />
R2;autumn;store2<br />
R1;spring;store1<br />
R1;autumn;store3</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://ykud.com/blog/coding/closed-cube-lattice-drawer/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Oracle Model clause in real-life )</title>
		<link>http://ykud.com/blog/bicpm/using-oracle-model-clause-in-real-life</link>
		<comments>http://ykud.com/blog/bicpm/using-oracle-model-clause-in-real-life#comments</comments>
		<pubDate>Tue, 01 Apr 2008 13:00:48 +0000</pubDate>
		<dc:creator>ykud</dc:creator>
				<category><![CDATA[BI&CPM]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[bi]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://ykud.com/blog/?p=209</guid>
		<description><![CDATA[I've been a long-term fan of oracle model by clause, talking about here and there, doing some small&#038;funny examples (like eight queens solution in one select) but lacked some real-life necessity to use it. It always turned out that partition by was enough, or some tricky analytical function was already built-in (like trend calculations I [...]]]></description>
			<content:encoded><![CDATA[<p>I've been a long-term fan of <a href="http://www.dbasupport.com/oracle/ora10g/model.shtml">oracle model by</a> clause, talking about here and there, doing some small&funny examples (like <a href="http://en.wikipedia.org/wiki/Eight_queens_puzzle">eight queens</a> solution in one select) but lacked some real-life necessity to use it. It always turned out that partition by was enough, or some tricky analytical function was already built-in (like trend calculations I <a href="http://ykud.com/blog/?p=201">wrote about</a>).<br />
And at last, I've encountered a suitable problem.</p>
<p>Task is quite simple&straightforward: calculate number of periods in which current stock will be sold in a store. Like: today we have sales enough for 3 weeks. That's a very common sales demand analysis parameter (Months of Sales (MoS), Weeks of Sales (WoS), DoS and etc).</p>
<p>Formula is quite simple: Current Stock / Average Sales over some period</p>
<p>But there were some difficulties in my case.<br />
<span id="more-130"></span><br />
I've got only partial data, some periods were completely missing, and the requirement was to treat missing sales data as zeros. And I also had to get the last known stock as current stock, because stock data could be missing too.<br />
Last stock is pretty easy to get using last_value oracle function, but getting average sales is hard. You cannot use fixed window width in partition by, since data can be missing. Moreover period varied other the years, so I've ended up adding up a field in time dimension called periods_ago, that contained time_key reference from which to sum sales.</p>
<p>So I've started with simple subqueries</p>
<pre class="plsql">&nbsp;
<a href="http://www.oracle.com/pls/db92/db92.drilldown?word=SELECT"><span style="color: #00F;">SELECT</span></a>
        time_key,
        product,
        company,
        sales_qty,
        <span style="color: #00F;">&#40;</span><a href="http://www.oracle.com/pls/db92/db92.drilldown?word=SELECT"><span style="color: #00F;">SELECT</span></a> <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=SUM"><span style="color: #000;">SUM</span></a><span style="color: #00F;">&#40;</span>sales_qty<span style="color: #00F;">&#41;</span>
           <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=FROM"><span style="color: #00F;">FROM</span></a> dwh.sales sales2
         <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=WHERE"><span style="color: #00F;">WHERE</span></a>
            sales2.product = sales.product,
            sales2.company = sales.company,
            sales2.time_key <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=BETWEEN"><span style="color: #00F;">BETWEEN</span></a> weeks.periods_ago <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=AND"><span style="color: #00F;">AND</span></a> sales.time_key
        <span style="color: #00F;">&#41;</span> <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=AS"><span style="color: #00F;">AS</span></a> running_sales_sum
<a href="http://www.oracle.com/pls/db92/db92.drilldown?word=FROM"><span style="color: #00F;">FROM</span></a>
        dwh.time_dim weeks, dwh.sales sales
        <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=WHERE"><span style="color: #00F;">WHERE</span></a>
           weeks.key = sales.time_key
&nbsp;</pre>
<p>and that is terribly slow on 10^6+ rows. ~20 minutes.</p>
<p>But with model by it'll be like:</p>
<pre class="plsql"><a href="http://www.oracle.com/pls/db92/db92.drilldown?word=SELECT"><span style="color: #00F;">SELECT</span></a>
        <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=TIME"><span style="color: #00F;">TIME</span></a>,
        product,
        company,
        sales_qty,
        last_stock_qty
<a href="http://www.oracle.com/pls/db92/db92.drilldown?word=FROM"><span style="color: #00F;">FROM</span></a>
        dwh.time_dim weeks, dwh.sales sales
        <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=WHERE"><span style="color: #00F;">WHERE</span></a>
           weeks.key = sales.time_key
      model
        IGNORE NAV
          <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=PARTITION"><span style="color: #00F;">PARTITION</span></a> <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=BY"><span style="color: #00F;">BY</span></a> <span style="color: #00F;">&#40;</span>product,company<span style="color: #00F;">&#41;</span>
            dimension <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=BY"><span style="color: #00F;">BY</span></a> <span style="color: #00F;">&#40;</span>time_key<span style="color: #00F;">&#41;</span>
            measures
            <span style="color: #00F;">&#40;</span>
                periods_ago,
                sales_qty,
                <span style="color: #800;">0</span> eight_weeks_sales_sum_qty,
                <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=NVL"><span style="color: #000;">NVL</span></a><span style="color: #00F;">&#40;</span><a href="http://www.oracle.com/pls/db92/db92.drilldown?word=LAST_VALUE"><span style="color: #000;">LAST_VALUE</span></a><span style="color: #00F;">&#40;</span>STOCK IGNORE NULLS<span style="color: #00F;">&#41;</span>
                OVER <span style="color: #00F;">&#40;</span><a href="http://www.oracle.com/pls/db92/db92.drilldown?word=PARTITION"><span style="color: #00F;">PARTITION</span></a> <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=BY"><span style="color: #00F;">BY</span></a> COMPANY, PRODUCT, SEGMENT, DISTRIB_LEVEL, SYSTEM
                <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=ORDER"><span style="color: #00F;">ORDER</span></a> <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=BY"><span style="color: #00F;">BY</span></a> <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=TIME"><span style="color: #00F;">TIME</span></a> <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=ASC"><span style="color: #00F;">ASC</span></a><span style="color: #00F;">&#41;</span>,<span style="color: #800;">0</span><span style="color: #00F;">&#41;</span> <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=AS"><span style="color: #00F;">AS</span></a> last_stock_qty
            rules   <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=UPDATE"><span style="color: #00F;">UPDATE</span></a>
            <span style="color: #00F;">&#40;</span>
                running_sales_sum<span style="color: #00F;">&#91;</span><a href="http://www.oracle.com/pls/db92/db92.drilldown?word=ANY"><span style="color: #00F;">ANY</span></a><span style="color: #00F;">&#93;</span> = <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=SUM"><span style="color: #000;">SUM</span></a><span style="color: #00F;">&#40;</span>sales_qty<span style="color: #00F;">&#41;</span><span style="color: #00F;">&#91;</span><a href="http://www.oracle.com/pls/db92/db92.drilldown?word=TIME"><span style="color: #00F;">TIME</span></a> <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=BETWEEN"><span style="color: #00F;">BETWEEN</span></a> periods_ago<span style="color: #00F;">&#91;</span>cv<span style="color: #00F;">&#40;</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">&#93;</span> <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=AND"><span style="color: #00F;">AND</span></a> cv<span style="color: #00F;">&#40;</span>time_key<span style="color: #00F;">&#41;</span><span style="color: #00F;">&#93;</span>
                            <a href="http://www.oracle.com/pls/db92/db92.drilldown?word=END"><span style="color: #00F;">END</span></a>
			<span style="color: #00F;">&#41;</span>
&nbsp;
            <span style="color: #00F;">&#41;</span>
&nbsp;</pre>
<p>around 3 minutes ) Notice the last stock calculation.</p>
<p>Here's a couple links to good model by examples:<br />
<a href="http://www.sqlsnippets.com/en/topic-11667.html">A wonderful tutorial at SQLSnippets</a><br />
<a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/sqlmodel.htm#i1011720">Official documentation restriction section</a> -- read that carefully</p>
]]></content:encoded>
			<wfw:commentRss>http://ykud.com/blog/bicpm/using-oracle-model-clause-in-real-life/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL worst practices</title>
		<link>http://ykud.com/blog/coding/sql-worst-practices</link>
		<comments>http://ykud.com/blog/coding/sql-worst-practices#comments</comments>
		<pubDate>Wed, 06 Feb 2008 08:22:33 +0000</pubDate>
		<dc:creator>ykud</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://ykud.com/blog/?p=203</guid>
		<description><![CDATA[If anything you do is somehow related to databases, you absolutely, definitely have to see these videos: Part 1:http://www.youtube.com/watch?v=40Lnoyv-sXg Part 2: http://www.youtube.com/watch?v=GbZgnAINjUw Part 3: http://www.youtube.com/watch?v=y70FmugnhPU Go the links from Tom Kyte's blog.]]></description>
			<content:encoded><![CDATA[<p>If anything you do is somehow related to databases, you absolutely, definitely <strong>have to see</strong> these videos:<br />
Part 1:<a href=" http://www.youtube.com/watch?v=40Lnoyv-sXg">http://www.youtube.com/watch?v=40Lnoyv-sXg</a><br />
Part 2: <a href="http://www.youtube.com/watch?v=GbZgnAINjUw">http://www.youtube.com/watch?v=GbZgnAINjUw</a><br />
Part 3: <a href="http://www.youtube.com/watch?v=y70FmugnhPU">http://www.youtube.com/watch?v=y70FmugnhPU</a></p>
<p>Go the links from <a href="http://tkyte.blogspot.com/2008/02/word-pathetic-never-sounded-so-good.html">Tom Kyte's blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ykud.com/blog/coding/sql-worst-practices/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle Data Integrator + Jython : How to drop all indexes on table</title>
		<link>http://ykud.com/blog/coding/oracle-data-integrator-jython-how-to-drop-all-indexes-on-table</link>
		<comments>http://ykud.com/blog/coding/oracle-data-integrator-jython-how-to-drop-all-indexes-on-table#comments</comments>
		<pubDate>Thu, 29 Nov 2007 12:07:29 +0000</pubDate>
		<dc:creator>ykud</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[odi]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://ykud.com/blog/?p=191</guid>
		<description><![CDATA[I'm currently building a warehouse using ODI, so I'll share some findings as it goes. And there's be Cognos BI on top of it and EP is one of the sources, so I'm still close to the roots ) Disclaimer: I'm Oracle &#038; ODI n00b -- there are (?) better ways of accomplishing these tasks [...]]]></description>
			<content:encoded><![CDATA[<p>I'm currently building a warehouse using ODI, so I'll share some findings as it goes. And there's be Cognos BI on top of it and EP is one of the sources, so I'm still close to the roots )</p>
<p>Disclaimer: I'm Oracle & ODI n00b -- there are (?) better ways of accomplishing these tasks and if you can point in right direction, i'd be eternally grateful.</p>
<p>So the task is to drop all indexes on a table before loading data (loading gets significantly faster, as they write in 1st grade textbooks these days). And not to specify every index to drop manually, since index are built by separate package and their names are not passed to loading part.</p>
<p>It can be done rather easy:<br />
1 Get all table indexes from ALL_INDEX table<br />
2 Form a drop command for every index<br />
3 Execute command</p>
<p>Couldn't figure a nice&clear way of doing it via sql procedure, but jython solution is easy. Table_Name is a procedure option telling what table's indexes to drop.</p>
<p>You can put such a step in Knowledge Module and get the option (Drop_Indexes) and use a substitution method getJDBCConnection(Target) instead of specifically writing out connection string to database. And beware of tables with same names -- it's not checked here.</p>
<p>Jython Procedure Code:<br />
<span id="more-111"></span><br />
<code><br />
import java<br />
# Set your connection. If including this as a step in IKM, you'd better use JDBCConnection substition method instead of 2 next steps<br />
driver, url, user, passwd = ('oracle.jdbc.driver.OracleDriver','jdbc:oracle:thin:@server:port:instance','user','password')<br />
# Register Driver<br />
java.lang.Class.forName(driver)<br />
# Create a Connection Object<br />
myCon =   java.sql.DriverManager.getConnection(url, user, passwd)<br />
# Create a Statement<br />
selectStmt =   myCon.createStatement  ()<br />
# Run a Select Query and get a Result Set<br />
selectRs =   selectStmt.executeQuery  ("select INDEX_NAME from ALL_INDEXES WHERE table_name = '<%=odiRef.getOption( "Table" )%>'")<br />
# Loop over the Result Set<br />
dropStmt =   myCon.createStatement  ()<br />
while   (selectRs.  next  ()):<br />
	dropStmt.executeQuery  ( "DROP INDEX " + "%s" %(selectRs.  getString  ("INDEX_NAME")))<br />
myCon.close()<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://ykud.com/blog/coding/oracle-data-integrator-jython-how-to-drop-all-indexes-on-table/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java vs K</title>
		<link>http://ykud.com/blog/coding/java-vs-k</link>
		<comments>http://ykud.com/blog/coding/java-vs-k#comments</comments>
		<pubDate>Fri, 27 Apr 2007 14:12:30 +0000</pubDate>
		<dc:creator>ykud</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[j]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[k]]></category>

		<guid isPermaLink="false">http://ykud.com/blog/?p=165</guid>
		<description><![CDATA[I spend some time tinkering with array-processing languages (think APL). They're so nice &#38; smooth when it comes to stats and multidimensional calculations. A nice video, showing how to solve Birthday problem in both Java and K (best of&#160; breed, core of KDB). It's all about counting probability of two people in a room having [...]]]></description>
			<content:encoded><![CDATA[<p>I spend some time tinkering with array-processing languages (think <a href="http://en.wikipedia.org/wiki/APL_programming_language">APL</a>). They're so nice &amp; smooth when it comes to stats and multidimensional calculations. <br /><a href="http://www.cs.nyu.edu/%7Emichaels/screencasts/Java_vs_K/Java_vs_K.html">A nice video</a>, showing how to solve Birthday problem in both Java and <a href="http://en.wikipedia.org/wiki/K_%28programming_language%29">K</a> (best of&nbsp; breed, core of <a href="http://kx.com/">KDB</a>). <br />It's all about counting probability of two people in a room having a same birthday date. 37 lines in Java and 44 symbols in J (a 17 chars solution is proposed in mailing list).<br /><a href="http://en.wikipedia.org/wiki/J_%28programming_language%29">J</a> is an open-source K analogue, just in case. </p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://ykud.com/blog/coding/java-vs-k/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Batch for log gathering + timestamping</title>
		<link>http://ykud.com/blog/coding/bat-file-log-gathering-timestamping</link>
		<comments>http://ykud.com/blog/coding/bat-file-log-gathering-timestamping#comments</comments>
		<pubDate>Tue, 05 Dec 2006 12:57:55 +0000</pubDate>
		<dc:creator>ykud</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[cognos]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://ykud.com/blog/2006/12/05/bat-file-log-gathering-timestamping/</guid>
		<description><![CDATA[When gathering logs, or performing backups, it's useful to append date suffix to the result file. But that's all not so trivial calculating such suffix in pure bat-files. We'll use system variables %date% and %time%. Try executing "echo %date%" and "echo %time%" from command line and watch the output. We'll append date suffix, and will [...]]]></description>
			<content:encoded><![CDATA[<p>When gathering logs, or performing backups, it's useful to append date suffix to the result file.<br />
But that's all not so trivial calculating such suffix in pure bat-files.<br />
We'll use system variables %date% and %time%.<br />
Try executing "echo %date%" and "echo %time%" from command line and watch the output.<br />
We'll append date suffix, and will show final result for time+date.</p>
<p>Suppose we need to rename the file test.txt to test_currdate.txt.</p>
<p>On my laptop "echo %date%" gives "05.12.2006".<br />
Be careful, output depends on regional settings (I've got Russian), so you'll need to modify this script.<br />
"test_05.12.2006.txt" doesn't look that good, I'd prefer "test_05122006.txt", so we'll need to calculate 05122006 from 05.12.2006.<br />
This can be done via :~ operator, allowing to cut substrings. Syntax is str:~start_position,length.</p>
<p>So the following line will calculate the variable currdate, holding "05122006".</p>
<pre class="winbatch">&nbsp;
set curdate=%date<span style="color: #FF1010; font-weight: bold;">:~6,4%%date:~3,2%%date:~0,2%</span>
&nbsp;</pre>
<p>rename command allows to change name of file, therefore you just run</p>
<pre class="winbatch">&nbsp;
set curdate=%date<span style="color: #FF1010; font-weight: bold;">:~6,4%%date:~3,2%%date:~0,2%</span>
rename test.txt test_%currdate%.txt
&nbsp;</pre>
<p>Script for grabbing specified files from servers below.<br />
<span id="more-63"></span><br />
This bat file accepts servernames as arguments and iterates through them to rename&gather all PlanningErrorLog.csv logs in one place (namely, C:\Logs).</p>
<pre class="winbatch">&nbsp;
@echo <span style="color: #0080FF; font-weight: bold;">off</span>
rem Gathering the Logs from command line arguments=servernames
rem directory <span style="color: #800080;">to</span> write
set destination=<span style="color: #ff0000;">&quot;C:Logs\&quot;</span>
set user=Admin
set pwd=~~~~~~~~
set log_directory=<span style="color: #ff0000;">&quot;WindowsTemp\&quot;</span>
set log_name=PlanningErrorLog
echo Monitoring %date% %time%&amp;gt<span style="color: #008000; font-style: italic;">;&amp;gt;c:logsmonitor_log.txt</span>
<span style="color: #FF1010; font-weight: bold;">:LOOP</span>
<span style="color: #800080;">IF</span> <span style="color: #ff0000;">&quot;%1&quot;</span> == <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #800080;">GOTO</span> <span style="color: #800080;">END</span>
net use \\%<span style="color: #cc66cc;">1</span>\c$ %pwd% /USER<span style="color: #FF1010; font-weight: bold;">:%1\%user%set curtime=%date:~6,4%%date:~3,2%%date:~0,2%_%time:~0,2%%time:~3,2%%time:~6,2%</span>
<span style="color: #800080;">if</span> EXIST \\%<span style="color: #cc66cc;">1</span>\c$%log_directory%%log_name%.csv rename \\%<span style="color: #cc66cc;">1</span>\c$\%log_directory%%log_name%.csv %1_%log_name%%curtime%.csv
&amp; xcopy \\%<span style="color: #cc66cc;">1</span>\c$\%log_directory%%1_%log_name%%curtime%.csv  %destination% /DY
net use /delete \\%<span style="color: #cc66cc;">1</span>\c$ /Y
<span style="color: #0080FF; font-weight: bold;">SHIFT</span>
<span style="color: #800080;">GOTO</span> LOOP
<span style="color: #FF1010; font-weight: bold;">:END</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://ykud.com/blog/coding/bat-file-log-gathering-timestamping/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cognos EP log analysis</title>
		<link>http://ykud.com/blog/coding/cognos-ep-log-analysis</link>
		<comments>http://ykud.com/blog/coding/cognos-ep-log-analysis#comments</comments>
		<pubDate>Tue, 21 Nov 2006 22:33:58 +0000</pubDate>
		<dc:creator>ykud</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[cognos]]></category>
		<category><![CDATA[ep cookbook]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[contributor]]></category>
		<category><![CDATA[ep]]></category>

		<guid isPermaLink="false">http://ykud.com/blog/2006/11/21/cognos-ep-log-analysis/</guid>
		<description><![CDATA[One of the main things I carried out of my alma-mater is passion for data. When you've got data, so many interesting things can be done . Various analysis, comparison, stats - just givе the data. That was a rather pathetic preambula. Let's get straight to business. Problem. On recent project I was doing some [...]]]></description>
			<content:encoded><![CDATA[<p>One of the main things I carried out of my <a href="http://www.msu.ru/en/">alma-mater</a> is passion for data. When you've got data, so many interesting things can be done <img src='http://ykud.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . Various analysis, comparison, stats - just givе the data.</p>
<p>That was a rather pathetic preambula. Let's get straight to business.</p>
<p><strong>Problem.</strong><br />
On recent project I was doing some technical support (<a href="http://ykud.com/blog/2006/11/14/memory-leaking-in-contributor/">dllhost problems</a>, if you recall, and more). It is a rather mature installation (about 8 months of production) with quite a number of servers, so logs contained around 100 Mb of data. And common question was -- ok, this error, did it appear before? When? Accompanied by what errors? What's the overall trend? Common patterns? Charts?<br />
All that analytical questions posed up on EP error logs.</p>
<p>As we all know, Cognos Contributor errors are recorded into PlanningErrorLog.csv files. And those log files contain rather detailed information, including ep version, module, time and, of course, error description.</p>
<p>I've tried to find some complete solution, but as usual on Microsoft platform, there are only paid tools, yet not solving the task completely.<br />
<strong><br />
Solution.</strong><br />
Having a whole Cognos 8 BI at finger-tips, I thought it would be nice to have all that errors in PowerPlay cube. I'm an OLAP-guy, after all.</p>
<p>So, technically the task was divided into 3 parts:</p>
<ol>
<li>Gathering the logs</li>
<li>Forming a datasource for Transformer</li>
<li>Creating a Transformer model and cube</li>
</ol>
<p>Step 1 is solved by .bat file -- I'll post it in separate as "Backing up with timestamping"<br />
Step 3 is quite straight-forward, if you have a single file, containing errors from multiple ones, except for time dimension as usual.<br />
More details on forming a datasource. Got no time? Skip to <a href="http://ykud.com/pics/wp/EP_Log_Analysis.jpg">this scheme</a> for overall picture.<br />
<strong>Merging the logs.<br />
</strong>At first I thought it was a rather simple task since the source files are csv (comma separated) and they just need to merged n to 1 with some additional transformations (adding top level error categories based on error desc, for example).<br />
It's never easy, I must admit.<br />
Well, csv is comma-separated for all but Cognos, PlanningErrorLogs are tab-separated. That's not a problem, let's get n tab files to csv.<br />
Planning logs contain some wonderful  pack of  unprintable chars(meant for Excel easy opening I hope, because there is no reason otherwise). In those chars there are some kind "EOF" chars, for example (I can see only their hex codes anyway), so VBScript cannot parse those files line by line correctly. There is a variant to open the file in Excel and save it to "normal csv", but that's impossible with 60 Mb log file I've got here.<br />
For sake of my nerves and Internet space I won't describe all other problems like parsing returned sql statements in error descriptions (those contain tabs and ";" in the same line).</p>
<p>Since I like Python much the final script is .py. It takes a directorу containing logs, merges them into 1 file, adds timesort values and error categories.</p>
<p>So that's the final scheme.<br />
<a href="http://ykud.com/pics/wp/EP_Log_Analysis.jpg" class="imagelink" title="EP_Log_Analysis.jpg"><img src="http://ykud.com/pics/wp/EP_Log_Analysis.jpg" id="image136" width="360" /></a></p>
<p>We add client servers to this sending net and plan to use 8 BI Event Notifier as technical support catalyst.</p>
<p>-----<br />
I'm eager to give out the scripts for the same reasons as I do this blog (also a dim hope that overall Cognos support will get better), so if you're interested - mail bark-bark ykud.com. A rather good error categorization can be created with some joined effort, imho.</p>
]]></content:encoded>
			<wfw:commentRss>http://ykud.com/blog/coding/cognos-ep-log-analysis/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Backups &#8212; they rock</title>
		<link>http://ykud.com/blog/bicpm/backups-they-rock</link>
		<comments>http://ykud.com/blog/bicpm/backups-they-rock#comments</comments>
		<pubDate>Tue, 14 Nov 2006 09:38:25 +0000</pubDate>
		<dc:creator>ykud</dc:creator>
				<category><![CDATA[BI&CPM]]></category>
		<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://ykud.com/blog/2006/11/14/backups-they-rock/</guid>
		<description><![CDATA[Had a wonderful evening yesterday, trying to recover a lost database. Well, got a lot experience with MS SQL and found a very useful program -- Lumigent Log Explorer. Recovering failed anyway. Had to redo it manually. When toying with gentoo, I've found a post, consisting of mostly "I'll always use logrotate" "I'll always use [...]]]></description>
			<content:encoded><![CDATA[<p>Had a wonderful evening yesterday, trying to recover a lost database. Well, got a lot<br />
experience with MS SQL and found a very useful program --<a href="http://www.lumigent.com/products/le_sql.html"> Lumigent Log Explorer.</a><br />
Recovering failed anyway. Had to redo it manually.</p>
<p>When toying with gentoo, I've found a post, consisting of mostly "I'll always use logrotate" "I'll always use logrotate" "I'll always use logrotate".<br />
Can't find it now, so tribute unknown.<br />
<strong> "I’ will always backup first" "I’ will always backup first"<br />
"I'will always backup first" "I'will always backup first"<br />
"I'will always backup first" "I'will always backup first"<br />
"I'will always backup first" "I'will always backup first"<br />
"I'will always backup first" </strong><strong> "I'will always backup first"</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://ykud.com/blog/bicpm/backups-they-rock/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>COM+ restarting</title>
		<link>http://ykud.com/blog/bicpm/com-restarting</link>
		<comments>http://ykud.com/blog/bicpm/com-restarting#comments</comments>
		<pubDate>Wed, 01 Nov 2006 11:17:54 +0000</pubDate>
		<dc:creator>ykud</dc:creator>
				<category><![CDATA[BI&CPM]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[cognos]]></category>

		<guid isPermaLink="false">http://ykud.com/blog/2006/11/01/com-restarting/</guid>
		<description><![CDATA[In heavy production we sometimes encounter situations, when Contributor COM+ or dllhost.exe grabs a lot of RAM and fails (or some contiguous memory errors). Cognos support recommends restarting COM on some schedule to fix such problems. In my experience this helps. Restart is very fast (less than a second) and rather reliable. So here are [...]]]></description>
			<content:encoded><![CDATA[<p>In heavy production we sometimes encounter situations, when Contributor COM+ or dllhost.exe grabs a lot of RAM and fails (or some contiguous memory errors). Cognos support recommends restarting COM  on some schedule to fix such problems. In my experience this helps.</p>
<p>Restart is very fast (less than a second) and rather reliable. So here are COM+ restarting scripts.</p>
<p>A .vbs script restarting desired COM component. Set desired component name.<br />
<strong>restart_com.vbs. </strong>Press more for code<strong>.<br />
</strong></p>
<pre /><span id="more-51"></span>And some bat file to do basic logging. <strong>restart_com.bat</strong>@ echo off<br />
rem restart specific COM+ component<br />
cmd /c "CSCRIPT.EXE restart_com.vbs /B /nologo"&gt;&gt;com_restart_log.txt</p>
]]></content:encoded>
			<wfw:commentRss>http://ykud.com/blog/bicpm/com-restarting/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Server-Side ASP Sleep</title>
		<link>http://ykud.com/blog/bicpm/server-side-asp-sleep</link>
		<comments>http://ykud.com/blog/bicpm/server-side-asp-sleep#comments</comments>
		<pubDate>Fri, 08 Sep 2006 13:45:34 +0000</pubDate>
		<dc:creator>ykud</dc:creator>
				<category><![CDATA[BI&CPM]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://ykud.com/blog/2006/09/08/server-side-asp-sleep/</guid>
		<description><![CDATA[While implementing an idea of web-based execution of Contributor Macros (see previous post), I've encountered the problem of some kind of progress-bar drawing in asp page. When user hit's asp page calling a Contributor Macro (which can take 15 min), he ought to see some action, telling him that "work is still going". Mine idea [...]]]></description>
			<content:encoded><![CDATA[<p>While implementing an idea of web-based execution of Contributor Macros (see previous post), I've encountered the problem of some kind of progress-bar drawing in asp page.</p>
<p>When user hit's asp page calling a Contributor Macro (which can take 15 min), he ought to see some action, telling him that "work is still going". Mine idea was to draw sequential line of blue squares.</p>
<p>So the ASP page code will be like that:</p>
<blockquote><p>set WScript = Server.CreateObject("WScript.Shell")<br />
set oExec = WScript.exec("c:\macro.bat")<br />
do while oExec.Status = 0<br />
response.write("&lt;img src='square.jpg'&gt;")<br />
response.flush()<br />
loop</p></blockquote>
<p>That's ok -- but it draws a square every computer "tick" <img src='http://ykud.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Can fill up a page in 2 secs.</p>
<p>A Sleep(5 secs) is needed in cycle body, just before response.flush()</p>
<p>But there's no sleep instruction in ASP. Workarounds are drastic.</p>
<p>* Create  an inner cycle to slow up execution. 100% CPU load -- very nice.</p>
<p>* Install a WaitFor dll. What, on every client site to use?</p>
<p>* Use an SQL to call Ms SQL Timeout function. Fantastic.</p>
<p>So we had to find another workaround for sleep. It quite fits in above mentioned list.</p>
<p>1 Create a sleep.vbs file with: "Wscript.Sleep 200000" (a very big number of your choice) line. A script to sleep forever.<br />
2 From ASP page run "cscript.exe /T:<b>your_time_to_sleep</b> sleep.vbs" . So it just stops sleep.vbs  execution on timeout of   <b>your_time_to_sleep.</b></p>
<p>Final code looks like:</p>
<blockquote><p>set WScript = Server.CreateObject("WScript.Shell")<br />
set oExec = WScript.exec("c:\macro.bat")<br />
do while oExec.Status = 0 response.write("&lt;img src='square.jpg'&gt;")<br />
Set WShell = Server.CreateObject("WScript.Shell")<br />
Wshell.run("cscript.exe /T:<b>your_time_to_sleep</b> sleep.vbs") response.flush()<br />
loop</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ykud.com/blog/bicpm/server-side-asp-sleep/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
