joeramsey.net

Loading IIS 6.0 Logs Into Oracle



First you need to create the table:

CREATE TABLE EMTCENTRAL.IISLOGS
(
LOGDATE          DATE,
LOGTIME           DATE,
S_SITENAME       VARCHAR2(50 BYTE),
S_COMPUTERNAME   VARCHAR2(32 BYTE),
S_IP             VARCHAR2(15 BYTE),
CS_METHOD        VARCHAR2(50 BYTE),
CS_URI_STEM      VARCHAR2(4000 BYTE),
CS_URI_QUERY     VARCHAR2(4000 BYTE),
S_PORT           VARCHAR2(6 BYTE),
CS_USERNAME      VARCHAR2(50 BYTE),
C_IP             VARCHAR2(15 BYTE),
CS_VERSION       VARCHAR2(4000 BYTE),
CS_USER_AGENT    VARCHAR2(4000 BYTE),
CS_COOKIE        VARCHAR2(4000 BYTE),
CS_REFERER       VARCHAR2(4000 BYTE),
CS_HOST          VARCHAR2(50 BYTE),
SC_STATUS        VARCHAR2(10 BYTE),
SC_SUBSTATUS     VARCHAR2(10 BYTE),
SC_WIN32_STATUS  VARCHAR2(10 BYTE),
SC_BYTES         NUMBER,
CS_BYTES         NUMBER,
TIME_TAKEN       NUMBER
)

Then create the sqlldr control file:

OPTIONS(ERRORS=9999999,SKIP=4)
LOAD DATA
INFILE iis.txt
TRUNCATE
INTO TABLE iislogs
FIELDS TERMINATED BY ' '
TRAILING NULLCOLS
( logdate "to_date(:logdate,'YYYY-MM-DD')",
logtime "to_date(:logtime,'HH24:MI:SS')",
s_sitename,
s_computername,
s_ip,
cs_method,
cs_uri_stem char(4000),
cs_uri_query char(4000),
s_port,
cs_username,
c_ip,
cs_version char(4000),
cs_user_agent char(4000),
cs_cookie char(4000),
cs_referer char(4000),
cs_host,
sc_status,
sc_substatus,
sc_win32_status,
sc_bytes,
cs_bytes,
time_taken)

Note: If you are copying the file from windows over into linux make sure to run dos2unix on the file first.

Written by wjramsey

December 12th, 2008 at 8:11 am

Easily Create Free Ringtones For iPhone With Just iTunes



1) Open iTunes

2) Listen to an audio file and determine the start and stop times you want to use.

3) Right click on the file and select “Get Info”

4) In the Options tab select the volume adjustment that you want and set the start/stop time

5) Click ok

6) Right click on the song and select “Create AAC Version”

7) Drag the created file to the desktop

8) Change the extension from .m4a to .m4r

9) Drag the file back into the iTunes ringtones library

10) Sync your iPhone

I know it’s 10 steps but you’d be suprised, this takes only a few seconds to do and it’s ultra-easy.  One other thing to note is to make sure to go back into “Get Info -> Options” for the original file and unset the start and stop times so it plays correctly.

This information comes from:

http://www.download.com/8301-2007_4-10056954-12.html

Written by wjramsey

December 11th, 2008 at 7:34 am

Posted in Uncategorized

Calculating Statistics For Function-Based Index Virtual Hidden Columns



I read a very interesting blog post the other day by Richard Foote entitled “Function Based Indexes and Missing Statistics - No Suprises.“  The post explains how in Oracle 10g that normal statistics are generated for function-based indexes but not on the underlying virtual hidden table columns that are created when a function-based index is added.

If Oracle knows the low value, the high value and the number of distinct values of the data associated with the function on a column, it can then accurately determine the associated selectivity and cardinality when the function is used on the column (assuming even distribution of data) and hence calculate an accurate cost and determine whether the use of the function-based index is appropriate.

However, and here comes the trap, when a function-based index is created, Oracle will now (since 10g) automatically calculate the statistics associated with the index (such as the blevel, number of leaf blocks, clustering factor, etc.) but it will NOT calculate the statistics associated with the hidden virtual column as these statistics are associated with the parent table, not directly with the index itself.

Therefore, even after you’ve created the function-based index, Oracle still has no idea on the selectivity associated the function because the necessary virtual column statistics are still missing. Oracle simply takes a “guess” and as with most guesses, it’s quite likely to be wrong which means the selectivity is likely to be wrong which means the costings is likely to be wrong which means the execution plan could very well be wrong as well.

After explaining the problem he goes on to provide the method by which to correct the issue.  I’ve created a simple script that will look at all of our tables with hidden virtual columns and create an analyze script to get these statistics for our environment.  To use elsewhere one would need to remove the reference to emtclientinfo.emtclients.

set pagesize 0
set linesize 200
set echo off
set feedback off
set timing off
set serveroutput off
spool analyze_hidden_virtual_columns.sql
select 'set echo on' from dual;
select 'set feedback on' from dual;
select 'set timing on' from dual;
select 'set serveroutput on' from dual;
select 'spool analyze_results.rpt' from dual;
select 'exec dbms_stats.gather_table_stats(ownname=>'''||owner||''',tabname=>'''||table_name||''',estimate_percent=>null,cascade=>true,method_opt=>''FOR ALL HIDDEN COLUMNS SIZE 1'');'
from dba_tab_cols
where lower(owner) in (select distinct(name) from emtclientinfo.emtclients)
and (hidden_column='YES' or virtual_column='YES')
group by owner, table_name
order by owner, table_name;
select 'spool off' from dual;
spool off

Written by wjramsey

December 8th, 2008 at 3:29 am

Posted in Uncategorized

Mac: Remove Alias Arrow Badge From Aliases



Right click on the icon(s) and select make Alias - this will create “shortcut icon”.  Now go to Finder->Preferences and switch off the Hard Disks,etc . The Alias will stay on desktop.

If you don’t want the arrow badges on the icons:

$ cd /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources

$ sudo mv AliasBadgeIcon.icns AliasBadgeIcon_OFF.icns

Written by wjramsey

November 30th, 2008 at 5:59 am

Posted in Mac Tips

Probing bind variable values for currently executing SQL



select s.sid,
s.username,
s.sql_hash_value,
s.sql_id,
s.sql_child_number,
spc.name,
spc.position,
spc.datatype_string,
spc.value_string,
last_captured
from v$sql_bind_capture spc, v$session s,v$sql sq
where s.sql_hash_value = spc.hash_value
and s.sql_address = spc.address
and sq.sql_id=s.sql_id
and spc.was_captured='YES'
and s.type<>'BACKGROUND'
and s.status='ACTIVE'
order by s.sql_id, s.sql_child_number,position

Written by wjramsey

November 26th, 2008 at 5:30 pm

Posted in Oracle