audit to crontab scripts

hi,
I have scripts which are running every 3 minutes. The scripts include connection to a database, using sqlplus. Sometimes, the connection fails (invalid username or password, locked user etc..) and the connection returns the error code, to the unix screen or to a file.
I want whenever there's a problem, to send a mail with the error code, I tried to returned the error code to a procedure as an input, but it fails...

You can replace your cron entries with a wrapper script that uses your cron script name as an argument and then the wrapper script can email your error codes/messages.

I'm sorry i'm very very new to unix.. how do I do this ?