Navin,
I do not use a MAC so I'm not sure you can run this directly from there. I run this on a Linux box that has Apache and PHP for Apache installed. I also have the PHP-MSSQL connector installed so PHP can make calls to my VCD DB on my MS SQL server.
You can do all of this directly from the SQL server if you want but if you need to do this very often you'll want to get this running on a web server.
Also, my query will only display vApp Templates and their Organization/Owner. If you want to include vApps the query will need to be changed. I can help you with that if need be.
I have tested that making changes directly within the DB will not hinder notification as long as you update the notification ticks column as well. Since I am setting stuff to never expire I am setting that column to NULL.
-Eric