Friday, July 17, 2009

Save Outlook attachements to disk

This handy bit of Powerscript code allows you to save attachements in your Outlook inbox to disk:

You need to pass a file name, not just a destination directory to SaveAsFile.The attachment has a FileName property.
This code groups attachments with same name and saves the first attachment in each group, if the attachment is corrupt or if it can't save it the Trap handles the exception; in this sample it just writes a message.You could also iterate through each group's attachments and append a different number to the name in order to save all.

$inbox=6
$outlook = new-object -com Outlook.Application
$inbox = $outlook.Session.GetDefaultFolder($inbox)
foreach ($group in $inbox.items % {$_.attachments} group filename) {
trap {
Write-Host There was a problem saving $fName
continue}
if ($group.Name.startswith("SECTSPDR")) {
$fName = "C:\TEMP\$($group.Name)"
$group.Group[0].saveasfile($fName)
if ($?) {Write-Host $fName was saved succesfuly.}
}
}

Backup options on your home network

I think I have settled on a good backup option for my desktop at home. I have an external hard drive connected to my desktop. Previously, I had installed rsync via cygwin which I have successfully used in the past. However, every few days I would find the process hung and had to reboot the machine. It appeared that this was not a common problem and it's not very easy finding support for free tools like cygwin (understandably)

Recently I cam across a tool similar to rsync from Microsoft named robocopy. This utility is included in the Windows resource tookit. It seems to be working well and have not yet found it hung like rsync was doing.

I also added an email to the job to mail the results of the run. For this I installed blat. I also had to hook into an SMTP server (using Gmail for this). Since GMail required SSL I needed to install and configure stunnel to communicate via SSL.

Thursday, June 19, 2008

Scientific Notation and SQL Loader

Sometimes you receive data in scientific notation. The way to handle this when using sql loader is to utilize the FLOAT EXTERNAL directive in the sql loader controlfile.

ex
STD_DEV FLOAT EXTERNAL

Wednesday, May 28, 2008

11G upgrade Heterogeneous Services quirk


Last week I went through an upgrade from 10G to 11G and had a problem with some dblinks I had setup to use the generic ODBC gateway. The links stopped working. The fix was to check the Enable Quoted Identifiers option in the DSN Advanced tab.

Also, as I was searching I found some suggestions to add the following line to the hs/admin/init.ora file(s)

HS_FDS_SUPPORT_STATISTICS=FALSE


Tuesday, May 13, 2008

Oracle on Windows nuances

Over the past year I have begun to support Oracle in a Windows environment. This experience hasn't been as horrifying as expected, however there still have been some nuances. here's my list:

  • Windows password changes suddenly prevent EM jobs from running. This is something you need to dicover as soon as possible
  • Restoring a database on Windows with RMAN requires there be a Windows service running for the database.
  • Removing software and Oracle Home assignments have always been tough on Windows (even for a client only install which I have worked with quite a bit). This is due to the registry mess and convoluted ways to manage environment settings in Windows.
  • "Logon as Batch' is required for Enterprise Manager jobs that will be running. This is assigned Via Control Panel Administrative Tools Local Security Policy Local Policies User Rights Assignment

Wednesday, May 7, 2008

RMAN switch to COPY

RMAN has a neat feature that allows you to switch the database to run on a backup copy (after recoverying it)

Setup:
-------
In order to set this up you need a datafile copy backup setup in RMAN.
example:
BACKUP FOR RECOVER OF COPY DATAFILECOPY FORMAT='T:\ImageCopies\ORCL\%d_%I_%N_%f' WITH TAG '%d_image_copy' DATABASE;

Make sure T:\ is independent from your current datafile(s) location

SWITCH example (USERS tablespace)
----------------------------------------
Now let's assume we had an i/o error on the file(s) associated with the USERS tablespace and we need to restore ASAP.

SQL "ALTER TABLESPACE users OFFLINE IMMEDIATE";
SWITCH TABLESPACE users TO COPY;
RECOVER TABLESPACE users;
SQL "ALTER TABLESPACE users ONLINE";

The above will redirect to the datafile copy, recover it, and bring it online so that the database operates with it.

Now, you probably want to redirect back to the original datafile location at some point. to do so, you would need to perform a new datafile copy backup in RMAN. Here, you would direct the copy to the ORIGINAL datafile location.

Here's an exmaple on how this would be done:
backup as copy datafile 'T:\ImageCopies\ORCL\ORCL_2575401446_USERS_8' format 'D:\oradata/ORCL\USERS_01.dbf';

After that run the same procedure outlined abovve to SWITCH the datafile. Oh, and assuming that all goes well, - take another backup!

Tuesday, February 26, 2008

Very busy TNSLSNR process

I encountered a problem with a listener running on a windows machine that had a 10G Oracle database and companion installed in separate ORACLE_HOMES. The ons.log file was HUGE under the companion install. And the listener was consuming the CPU. I found some posts on OTN compaining of the same. It turned out that there was a config problem with the opmn process. Changing the ports in the ons.cnfig and in opmn.xml files solved the problem.

The errrs in the ons.log file were of the form:
Date Time Local connection 0,127.0.0.1,6100 missing form factor.