## Tuesday, April 24, 2007

### How to know what table is linking to the row you are trying to delete

You are trying to delete a row in a table but b/c of the db constraint you can't, here how to find out what table is causing the issue.

In oracle you would get an error like this:
ORA-02292: integrity constraint (TESTDB.FK_REF_114571) violated - child record found

select * from user_constraints where constraint_name = 'FK_REF_114571'

In MSSQL
select * from INFORMATION_SCHEMA.constraint_column_usage
where constraint_name = 'FK_REF_114571'

## Friday, March 30, 2007

### How to copy data between 2 different Oracle or MSSQL database

Well what if you did not do a backup of your data and you deleted the wrong stuff. Import your backup database on the same server. Login with a user that have access to both DB, system should work.
Oracle to Oracle:
insert into productiondb.bill_detail select * from backupdb.bill_detailwhere not exists(select *from productiondb.bill_detailwhere bill_id = backupdb.bill_detail.bill_id)
This query will copy everything that is missing back into the production DB.

MSSQL to MSSQL:
Here's how I populated nd_loc and it took only 10 or so seconds to copy ~150,000 rows! First connect to the production db and then create the link to the backup server. By running the command "sp_addlinkedserver sqldev" (where sqldev is the other server name where the backup db is. You don't have to do this if both db are on the same server)

insert into nd_loc select * from sqldev.backupdb.dbo.nd_loc

Now why can't their damned odbc driver be that fast? (Thanks Scott for the tips)

### How to create a table from a select statement

Ready to make a big update, before you do make a backup of that data into a temp table with a select. This save me few times.
create table tmp_eric as ( select * from ... where ... )

Each columns returned from the select will become the columns of the new table tmp_eric.

For MSSQL, you need to first create the table then you can use the insert

create table tmp_eric (col1, INTEGER PRIMARY KEY, col2...)insert into tmp_eric (col1, col2,...)select col1, col2,... from ericYou can also use:select * into tmp_eric from eric

## Saturday, March 17, 2007

### How to make Final Cut work on pre-AGP older Macs

I could not get my Final Cut Express v2 working on my iMac G5 until I found this info, and now it's working like a charm. ;-)

(from the June 26th, 2003 www.xlr8yourmac.com news page)
A reader sent a note on a link with info/workaround for installing Final Cut Pro 4 on an older Mac:
" Mike, Found the hack for FCP 4 on a non-AGP Mac. I'm attaching text file but I'm also sending you the 2-pop link where I got the info from. Please don't attribute this to me. #1) I didn't figure it out. #2) I think Apple doesn't like me sometimes. We're definitely getting a Dual G5, though. This is the Mac we've all been waiting. In the meantime though, this hack works perfectly. ENJOY! Here's the 2-pop link." (Note - that link gets a 404/not found today so here is a copy of the attached info he sent on the patch) "I didn't see this posted anywhere. I have a Blue and White G3 that I upgraded to a G4 500. I didn't realize that FCP4 didn't work with PCI macs until I launched it and was given the message: no AGP card on your machine.
I was able to get around this and have been editing happily since.

• Control-Click on the Final Cut Pro application and select show package contents.
• Open the contents folder and open info.plist.
• Search for AGP replace it with PCI.
• Save and close the file.
• Open FCP4, and voila it works.

I have 684 mb of ram. My playback is smooth, rendering is pretty fast. I have yet to encounter a scenario where it doesn't work

## First figure out the IP of your DVR then just add https:// in front (notice the s)

https://192.168.1.30/

The best transfer rate I get is around 600 KB/sec, it take for ever to download those 1-2 GB files...

### How to copy files using tar without a tar file / How to tar and untar without a tar file.

# why do this, well tar keep the ownership and permission of the files
# where cp -r will make everything own by the user doing the copy.

(cd / ; tar cf - home) | (cd /newhome; tar xvf -)

### How to partition/format a disk under linux

fdisk /dev/hda

# Now that you partitioned your disk let's format it (man mke2fs)
mke2fs /dev/hda1 <--- you have to do this for each partition you created, just replace 1 for partition #

### How to mount a webdav share with a comand line

## Here is the command I use to mount a test webDav share on my Mac OS X / unix

/sbin/mount_webdav -o noautomounted -o browse -a15 -vmyfotoz http://localhost:8080/ /Volumes/myfotoz/

### How to rsync data from one UNIX server to an other

## Like lots of people I have lots of pictures online, 36 GB... I don't want to lose those preciouses ## memories, so I setup a cron to rsync my data every weeks. The beauty of rsync is that it won't ## copy what's has not change. For more info on rsync just type: man rsync

cd /backup/
rsync -rlptgov root@thibeault.cc:/path/to/my/photos/on/thibeault/cc/ photos/

## here if you like to snoop around my photo Album.
http://thibeault.cc/photoAlbum/

### How to mount an iso on Linux

# First imagemount -t iso9660 -o ro,loop=/dev/loop0 FIRST_TRIP.iso /mnt# Second image (make sure mnt2 exist)mount -t iso9660 -o ro,loop=/dev/loop1 LAST_TRIP.iso /mnt2

### How to create an iso image on linux (dd/mkisofs)

# How to create the content of a directory into an iso image
## if you mount an unprotected DVD under /dev/disk2/
## Here how you can make an iso file from it.

dd if=/dev/disk2 of=FIRST_TRIP.iso bs=256k

or

cd /dev/disk2
mkisofs -r -o ~/FIRST_TRIP.iso .

## Friday, March 16, 2007

### How to Batch Uppercase/lowercase file/directory

## under tcsh shell

# make the directory lowercase...
foreach f ( find . -type d -print  )
mv $f echo$f | tr A-Z a-z
end

# make the file lowercase...
foreach f ( find . -type f -print  )
mv $f echo$f | tr A-Z a-z
end

### How to Batch Change file names under tcsh

## example: for each file ending by .jpg, replace any spaces with underscores

foreach i (*.jpg*)
echo $i > /tmp/nom set j=sed -e '1,$s? ?_?g' /tmp/nom
mv "$i" "$j"
\rm /tmp/nom
end