NOthingyoumissed

George Mauer is on the Net

Goodbye wordpress.com

I finally got off my ass and installed my own version of wordpress so I’m moving this blog (such as it is) over to http://georgemauer.net/blog/ If you really care look there for updates.

June 19, 2009 Posted by | Album | Leave a comment

New Years Resolutions

Ok, so just like everyone else in the universe I’m posting some resolutions on my blog.  The first and most obvious if you look at the dates of my previous posts is to blog more.  A heck of a lot more.  I’m aiming for once a week.  Nothing intense, I’m no Steve Yegge and I don’t have all that much to say but I do have some thoughts that I need to start writting down and I do need to practice my writting. 

That being said, some career development-oriented resolutions:

  • Attend at least one professional – preferably an ALT.Net centered – conference.  Got to figure out which one first.
  • Learn about continuous integration and how to use a build system.  I am thinking NANT, CruiseControl.NET or TFS.  I just want to be able to build all these awesome open source projects so that I can…
  • …read other people’s code.  For all my complaining of being a lonely developer working in a godawful architecture I certainly make few enough attempts to connect with well written code.
  • Learn more about dynamic languages.  I have spent plenty of time in the PHP world and I’ve got to say, I just don’t get it.  Yes some tasks can be done with slightly less code, but you have to give up such IDE luxuries like Intellisense and automatic refactoring.  With all the chatter lately of Ruby and with IronRuby 71% complete maybe I’ll try my hand at that. 
  • Javascript.  Find an excuse to get beyond the basics.  I think it is a language with much to teach me and I want to learn.  It doesn’t hurt that JQuery as about as awesome as can be.
  • Learn more about .NET internals and the CLR.  I would love to be able to get a deep enough understanding to design my own language – not that I have any intention of doing something so crazy.

January 1, 2009 Posted by | Album | Leave a comment

Backing up and Restoring Databases in Oracle

This article is specifically about how to use oracle’s exp and imp utilities to create a dump file of all objects contained within an Oracle User(s) including the schema, procedures, package, constraints, sequences, jobs, and data; pretty much everything except DB Links. When you are done, you should be able to back up a database and restore it at a future date.

What you will need for this:

  • Oracle installed on your machine (You can download Oracle XE for free here)
  • A Database to back up (Sample schemas here, but then again you probably have one if you’re reading this)
  • Windows (maybe?) – I have no clue how this process works on a Linux or Mac system, though I imagine it’s exactly the same.

Creating a Backup

An Oracle install typically comes with the excellent exp command line utility (also there’s similar the exp data pump) to see if it’s installed and its manual type at the command prompt:

C:\Temp>exp -?

There are many articles online explaining this utility. The important parameters here for a simple, straightforward backup of a user are OWNER and FILE. Since the command line utility is not within oracle you don’t have to mess around with oracle directories or permissions or anything like that. To backup a database type:

C:\Temp>exp scott/tiger@XE owner=(scott) file=scott.dmp

Break it down:

  • exp – start our utility, don’t be silly
  • scott/tiger – the username/password of the account we will be using to pull out the information. It can be any account with the ability to access the user schema you’re trying to save, I usually just use the same schema
  • @XE – An ‘@’ symbol followed by the TNS name for the oracle instance the database you’re backing up is in, look in your tnsnames.ora for installed names. Do not omit this, as the utility might have a default and you might end up backing up the wrong database.
  • owner=(scott) – a comma separated list of users you want to back up. We could have used owner=(user1,user2) or – when there is only one user – owner=user1.
  • file=scott.dmp – the file that the backup will be stored in. The above set-up will create c:\Temp\scott.dmp with the contents of everything that is owned by the scott User in the XE instance of Oracle.

Restoring the Backup

This part is (slightly) more difficult. The command line utility to use is called imp

C:\Temp>imp -?

The important parameters are FILE, TOUSER, FROMUSER

Because you exported everything owned by a user, you must first ensure the user exists in the garget database. You can do a CREATE USER SQL statement or, if using the Toad for Oracle client you can use the Create User pop-up.

If the user already exists however and you want to restore them to the saved state you must first remove all of the user’s objects. The easiest way to do this is to drop and recreate your user. In Toad you can select the user from the Users view and click on the Script tab to see a script for dropping and restoring the user. In the case of the Scott Schema you would see

DROP USER SCOTT CASCADE;

CREATE USER SCOTT

IDENTIFIED BY VALUES ‘F894844C34402B67’

DEFAULT TABLESPACE USERS

TEMPORARY TABLESPACE TEMP

PROFILE DEFAULT

ACCOUNT UNLOCK;

— 2 Roles for SCOTT

GRANT RESOURCE TO SCOTT;

GRANT CONNECT TO SCOTT;

ALTER USER SCOTT DEFAULT ROLE ALL;

— 1 System Privilege for SCOTT

GRANT UNLIMITED TABLESPACE TO SCOTT;

Notice that there are actually six SQL statements here (count the semi-colons), you must run them all in order. (First drop the user, then create the user, then grant roles, etc.). Also notice that the password is stored as an encrypted hash value; ‘F894844C34402B67’ is the encoding of the ‘tiger’ password. If you would like to change the password just take out the values keyword: IDENTIFIED BY ‘MyNewPassword’.  Otherwise, keep the line as is.  Finally, since you are dropping and recreating the user notice that you must be logged in from a different user account – one with the permissions to do so. If you have access to the System user it will do nicely, this is the only time that you need to be logged in as a different user, make sure you get in and get out as quickly as possible to minimize potential damage.

Now with the Scott user created and cleared of any objects that might conflict with the ones we are trying to restore, we are ready to run the import.

C:\Temp>imp scott/release1@XE file=scott.dmp fromuser=(scott) touser=(scott)

Break Down:

  • imp scott/release1@XE – just like explained above, what user should the utility log in as when doing the import and at what Oracle instance. The user should have permissions to create tables, packages, etc. and to insert data.
  • file=scott.dmp – a file created by the exp command described above
  • fromuser=(scott) – since the .dmp file can create objects for multiple users, will search the file for all objects owned by this user(s) and import those. When there is only one user we can also omit the paretheses.
  • touser=(scott) – the objects we’re importing will be created need to be owned by a user already in the database, this is the user they will be created under. If our target database had two empty users scott and allan, and we did something like imp scott/release1@XE file=scott.dmp fromuser=scott touser=allan then the end result is that scott will still be empty but all of the objects saved to the file from the scott user will now have been imported to the allan user.

And you’re done. Don’t forget to check for invalid objects if you are transferring data between two different oracle instances or users. Enjoy!

 

Errors That I’ve Commonly Run Into

· You are attempting to run imp and you get IMP-00015: following statement failed because the object already exists scrolled to the screen. Generally this means that you forgot to empty the target user. Drop and recreate them or manually drop all the objects the import is complaining about.

· You are attempting to run imp and you get IMP-00010: not a valid export file, header failed verification. This in my experience is caused not so much by a mismatch in the versions of Oracle as Google would suggest but by a mismatch in the versions of the exp and imp utilities. For example if I go to my Oracle Server I can check the version of the export utility

C:\Documents and Settings\Administrator.WESTWAY-AD1>exp

Export: Release 10.2.0.1.0 – Production on Wed Jun 25 16:50:19 2008

 

And if I try the same thing on my Desktop I get:

C:\Temp>exp

Export: Release 9.2.0.1.0 – Production on Wed Jun 25 16:49:27 2008

You will have to find and download the same version of each. Sorry about that.

June 25, 2008 Posted by | Album | Leave a comment

QuickTime and a TIFF (Uncompressed) decompressor are needed to see this picture

Microsoft Office on a Mac can’t save imagesQuickTime and a TIFF (Uncompressed) decompressor are needed to see this picture

I have run into this problem a few times and I figured I’d blog about it both to vent my frustration and to make a note for the next time this comes back to haunt me.

So you get a shiny new Macintosh, you fire it up to discover that the friendly folks over at apple have pre-loaded it with the Mac version of Microsoft Office. Including Excel, PowerPoint, and your favorite word processor Microsoft Word! (Oh just admit it, you’ve never tried a different one.) So you fire it up and start pumping out document after document. It’s wonderful; you get the familiarity of MS Office with the slickness of a Mac. You format up your word file, place a nice logo or banner image as a header and you send it to your friends, or Wendy down in marketing, or even worse your boss. They are of course not enlightened like you; they’re still using that old bludgeon, a Windows PC. Oh well, at least you’ll get to brag to them later about your increased productivity and transcendent, almost religious, user experience. And then you get the call: “These pictures aren’t working!” they cry. You send them the file again – perhaps it got corrupted in email transit – but no, the problems persist. After half a day of this you are forced to trek over to the foolish nonce’s computer to witness for yourself how they are possibly managing to screw this simple process up. You make sure the files are identical – same checksum, no corruption and you open it up to see…to see:

“QuickTime and a TIFF (Uncompressed) decompressor are needed to see this picture.”

Huh? Excuse me? Where are your images? Does QuickTime suddenly have something to do with Word? Does the Word spelling dictionary even recognize ‘decompressor’ as a valid term? The answers are, in order: They’re there but invisible, it does on a Mac, and an emphatic no.

I don’t know if it was laziness, an evil marketing ploy, or what but it seems like the team responsible for the Mac version of MS Office used QuickTime image compression for storing some formats of embedded image files. The upshot of this is that those images are not visible on a PC, will never be visible on a PC, and you’re going to be left feeling frustrated, embarrassed, and probably a little violated. God forbid this was a powerpoint file.

The solutions to this quandary aren’t good. You basically have to either reinsert the images into the file on a PC or convert the images on the Mac to uncompressed bitmaps, re-insert them, and re-save the file with no compression. Needless to say this is awful programming. Really like mid-90s Windows 95 level bad. I actually would not be surprised if this WAS a dickish screw you to Mac users from somewhere deep in the Microsoft psyche (read marketing). Either that or they just didn’t feel like porting that part of the software properly. This has also been a problem for a long time with no effort by the powers that be for a resolution. Just when I was starting to think that Micro$oft ain’t all that bad. Sigh.

So in conclusion what’s the final word? Well there is one solution, and – you might have guessed it by now – it’s called Open Office. Presto! Now don’t you definitely feel better than that silly co-worker/boss of yours?

that are viewable on a PC?

May 12, 2008 Posted by | Album | 3 Comments