Worth noting is that:
1) The key and data will, by default, be unencrypted between the database client and server (i.e. your application and the database) in the most popular RDBMSes.
1a) This is a sniffing threat as well as a MITM threat.
2) As a symmetric cipher, knowledge of the AES key is a necessary and sufficient condition to either encrypt or decrypt the data. In other words, if a server has the key stored, breaching that server provides enough information to decrypt everything encrypted with that key.
3) There are companies who specialize in securely handling data like this. It's one of those things that is somewhat complex, very specialized, and at a high risk of great catastrophe should a simple, subtle mistake be made. It's like radioactive waste.
If you do decide to roll your own, be sure to run it past your attorney and insurance company, to ensure that you're doing so legally and with adequate financial protection. People tend to get bent out of shape about credit card numbers, which are easily invalidated/replaced and leave little lasting damage;
imagine how cranky folks would get if SSNs were leaked.
_________________
Code:
/* TODO: need to add signature to posts */