on May 15th, 2008Nerd Notes: A Couple of Things To Remember (+ Sad Kermit)

Most of you will never need to know this, but someday someone will search google and find this and thank the lazyweb that I wrote them down. Non-nerds can scroll to the bottom for Sad Kermit.

Unix: TAR and file permissions

Use the P flag dummy

When you un-archive a file using tar use the -p switch to preserve the original file permissions and ownership. That way when your FTP process runs to get the next day files and you forgot to delete the file you unarchived your FTP process won’t die because it gets a file permission error and then ruins everybody’s daily financial report from your fortune 200 company.

And if you remember to do this you won’t have to get 100 emails all shouting, “Oh NOES sky be fallins nows!”

Just something to think about.

Oracle:Load Multiple Columns from a Single Column With SQLLDR

Ok, this is actually pretty neat.

Lets say you have a table, PARTS_TEST, with columns:

FULL_PART_NAME

UPC

SKU

PART_NAME1

PART_NAME2

and the comma separated data looks like:

WIDGET-ABC, 1234567, 1234567890

And you need to split your first field into two fields for columns PART_NAME1 and PART_NAME2 (WIDGET and ABC respectively.)

Here’s how you do it:

Go ahead and load your first fields as normal and then at the end you can reference FULL_PARTS_NAME as a bind variable and use string functions on it.

Load Data

into table PARTS_TEST

(

FULL_PART_NAME,

UPC,

SKU,

PART_NAME1 “substr(:FULL_PART_NAME, 1, 6),

PART_NAME2 “substr(:FULL_PART_NAME, 7, length(:FULL_PART_NAME))”

)

The only caveat is that you have to pad your comma separated file with extra blank spaces to accomodate your additonal columns you’re loading.

Ok, that’s all the nerdery.

Now lets all watch Sad Kermit sing Elliot Smith’s “Needle in the Hay”.

Comments are closed at this time.