CTAS disregards number precision and scale

When using a "create table as select" (CTAS) to create a table based on a query, when that query also contains a window function/analytical function in the SELECT-clause, results in the precision and scale being omitted.

The precision/scale are neglected, when running the following example in Oracle 11g:
CREATE OR REPLACE FORCE VIEW VSA_X AS
SELECT
CAST(1 AS NUMERIC(10,2)) AS FLD1,
ROW_NUMBER() OVER (PARTITION BY 1 ORDER BY 1) AS RN
FROM DUAL;

DROP TABLE X;

CREATE TABLE X AS SELECT * FROM VSA_X;
Table X will have no precision/scale for FLD1. It is bypassed and will simply have NUMBER for its datatype. This is a bug in Oracle.

Note:
  • Using NUMBER in stead of NUMERIC makes no difference, the bug is still there.
  • Explicitly casting the ROW_NUMBER() function also makes no difference.
Solution:

Put the window function inside a derived table:
CREATE OR REPLACE FORCE VIEW VSA_X AS
SELECT
CAST(FLD1 AS NUMERIC(10,2)) AS FLD1,
RN
FROM
(
  SELECT
  1 AS FLD1,
  ROW_NUMBER() OVER (PARTITION BY 1 ORDER BY 1) AS RN
  FROM DUAL
) x;
Keywords: CTAS omits precision, CTAS omits number precision, CTAS bypasses precision, CTAS bypasses number precision.

Subtitle Workshop blank screen with Matroska/MKV containing H.264

Scroll down to solution for the workaround to get video in stead of a black screen. Read on for a little bit more background information.

There are five components to video in Windows: container (like avi, mkv), video format (divx, h.264), splitter, decoder, and video player.

Nice post to get started:
http://www.hack7mc.com/2009/02/mkvs-for-minimalists-on-windows-7.html

But the scripts could be more robust. E.g. change the fixed system root "c:\windows" to %systemroot%

SPLITTERS

Haali Media Splitter: http://haali.su/mkv
Note: since december 2009, this contains also the x64 version.

Gabest: hard to get, but is part in some packs.
x32: http://www.hack7mc.com/wp-content/plugins/download-monitor/download.php?id=12
x64: http://www.hack7mc.com/wp-content/plugins/download-monitor/download.php?id=11

Advice: Haali splitter.

DECODERS

ffdshow (the original, but outdated): http://sourceforge.net/projects/ffdshow/files
ffdshow tryouts: http://sourceforge.net/projects/ffdshow-tryout/files

Get a 64 bits or 32 bit ("generic") in the folder "official releases" or get a more recent nightly build from the folder "SVN builds by clsid".

Advice: a recent 32 bit nightly build.

SPLITTER/DECODER packs

K-Lite Codec Pack: http://www.digital-digest.com/software/K-Lite_Codec_Pack_64-Bit_history.html

Shark007: Install Win7Codecs first (http://www.majorgeeks.com/Win7codecs_d5959.html), then x64Components (http://www.majorgeeks.com/download.php?det=5535)

Shark's Win7Codecs comes with a tool to select and configure the various splitters and decoders for the various media types (divx/xvid, mpeg2, h264/mpeg4) and containers (avi, mkv).

Install and use the "settings32.exe" application to configure, since most video players are currently still 32 bit (winamp, zoomplayer)

Advice: Shark007 packs

VIDEO PLAYERS

Zoomplayer 5.02 Standard (latest free version), Windows Media Player (build-in, WMP Classic/Guliverkli2 or WMP Classic Home Cinema) and Winamp all work with the system splitters and decoders. VLC Player comes with its own splitters/decoders and does not use the ones installed on the system.

Subtitle Workshop v2.51 does only work with "real" avi containers. The "rename trick", where the mkv extension is changed to avi, will work with most of the video players, but unfortunately not with Subtitle Workshop.

The more recent betas of v4 do work with mkv/h.264 files, but those are not very stable. The splitter has to be Haali, Gabest's does not work - "cannot render media!". It does not matter if the "rename trick" is used. This also applies to Windows Media Player. Gabest also doesn't work with Subtitle Workshop v2.51.

Winamp doesn't really like mkv files; it almost always halts on startup.

Zoomplayer does not work well with video format "Xvid dev 25-Mar-03". You have to use Haali splitter for avi, because Gabest and Microsoft's cause a stack overflow.

Zoomplayer doesn't work with mkv/H.264 when the ffdshow codec is used.

CHECK TOOLS

Tools to check video containers, e.g. get video format or the the processing workflow (splitting, decoding):


SOLUTION

To get the video preview to work in Subtitle Workshop 2.51 with mkv files, that contain the h.264 video format:
  • Install both Shark007 packs mentioned above. Check the box to install ffdshow.
  • To get the latest ffdshow version working with Shark007 (this step is not necessary):
    • In \program files (x86)\win7codecs\filters: regsvr32 /u "ffdshow.ax". Uninstall this older version
    • Download most recent 32 bit nightly build mentioned above and install with default settings
    • Copy "ffdshow.ax" from the nightly build install folder to the \win7codecs\filters folder
  • Start \program files (x86)\win7codecs\tools\settings32.exe
  • Click "reset all" to get the recommended configuration. 
    • To be sure, check the following settings:
      H264: use ffdshow's codec/ffdshow with multithreading
      MKV: use haali splitter
  • Set H264 codec in directshow players to "use ffdshow's codec"
  • Finally, install Vobsub 2.23
Notes:
  • The final step is very important. You have to install Vobsub (or "vsfilter") as the final step, even if it is already installed. Just install it again. (VobSub is a directshow filter that overlays subtitles)
  • Test mkv and avi video formats in Winamp and Zoomplayer. If they fail to start, then uninstall Vobsub 2.23 again. Use the subtitle option from ffdshow to have subtitles in those players. WMPC and VLC have their own subtitle overlay filters.
  • The version has to be 2.23, more recent versions will not work. E.g. 2.39 does not work.
  • Do not rename the container from .mkv to .avi. Subtitle Workshop 2.51 will load the .mkv extension without problems.

TNS service names ODBC dropdown box garbled, messed up, gibberish

Most likely cause is that there are two or more different Oracle clients installed, with two or more home folders and tnsnames.ora files.

For example, an Oracle 10 client is installed or Oracle XE is installed. Both contain a home folder with tnsnames.ora. Later, the Oracle 11g instant client + ODBC compontents is added. Now there are two home folders.

In this case, the TNS_ADMIN environment variable needs to exist:
  • Create TNS_ADMIN variable via control panel -> system -> advanced -> environment variables -> system variables
  • Set is to one of the admin folders, eg.:
    c:\oracle\ic_x32_11.2.0.1.0_basiclite\NETWORK\ADMIN
    Note: make sure is contains the tnsnames.ora, sqlnet.ora and listener.ora files.
  • Create a ODBC connection using the Oracle driver and check if the "tns service name" dropdown box contains readable entries
  • Just to be sure, replace the body of all other tnsnames.ora files with:
    IFILE=c:\oracle\ic_x32_11.2.0.1.0_basiclite\NETWORK\ADMIN

CDBurnerXP: drive not recognized

CDBurnerXP is a freeware tool for burning CD's and DVD's, including blueray. However, it sometimes does not recognize the drive to burn with.

First, check the FAQ on the CDBurnerXP website:
http://cdburnerxp.se/help/appendices/troubleshooting

In my specific case, I then did the following:
  • Start CDBurnerXP in "audio mode"; the drive was recognized. Only in "data mode" it is not.
  • Check the chipset. Download the freeware tool "system info": http://www.gtopala.com/siw-download.html.
  • Extract and start it - it does not have to be installed; it is a standalone executable. Check hardware -> motherboard -> southbridge. Note the chipset.
  • Download "intel matrix storage manager" for your chipset: IMSM.
  • Install IMSM and restart.
Now, CDBurnerXP should work in "data mode".

Note: make sure the drive is on the "compatible drives" list: http://cdburnerxp.se/en/testeddrives

The nearby-future of storage

The ioDrive Duo by FusionIO out-performs even multiple SSD's placed in parallel. The 320GB version of the ioDrive has a read/write speed of ~1.5GB/s:

http://www.fusionio.com/products/iodriveduo

Difference with traditional SSD:
  • The flash memory is integrated in the PCI card.
  • The flash memory has been optimized using a proprietary technology.
Downside:
  • Cannot be used as a boot drive.
  • Requires a 64-bit operating system.
  • The price is about 15,000 euro for 320GB version (ssdeurope.com). Ofcourse, this has to be compared against the cost of buying and operating a SAN.

SQL Server statistics

Statistics are information about the distribution of data in a column, maintained internally by the database engine.

Rules and behaviour with regard to statistics, when automatic creation/updating is turned on:
  • Statistics are automatically created when creating an index, but only for the first column of the (composite) index.
  • Statistics can be created manually on any column or combination of columns.
  • Statistics are automatically created/updated when the query optimizer finds need for them.
  • Statistics are not automatically created/updated when the server is too busy, unless the "update statistics asynchronously" option is turned on, because then the are created in parallel.
  • Asynchronously created/updated statistics have effect the next time the (causing) query is run.
Links:
http://www.sql-server-performance.com/tips/update_statistics_p1.aspx
http://blogs.technet.com/b/rob/archive/2008/05/16/sql-server-statistics.aspx
http://technet.microsoft.com/nl-nl/library/cc966419(en-us).aspx

Set cscript as default script engine

To set cscript as the default scripting engine on the system:
cscript //h:cscript //s
This way, the "wscript.echo" method always spools to the command line in stead of to message boxes. And without the need to start each script with the "cscript.exe" application.