by adamors · 12y ago · 0 comments
Last time I tried writing stored procedures I went into a deep depression from the lack of a proper IDE/editor/debugger/tester/anything.
Is there any process out there besides time consuming trial and error? Or does everyone who writes these knows them by heart and I should just stick to programming languages?
Honestly I don't understand how anyone can do more than a basic query in the command line for PostgreSQL. I've been using EMS's PostgreSQL Manager (www.sqlmanager.net) for years. Has auto-complete, even from local aliases. Named, numbered, parameters. Provides base templates for your BEGIN and END, and lots of other goodies. I could work without it, but it would be much more time consuming. I do however, practice most things in the SQL Editor first. Though it does have good built in analysis, sometimes it's nice to just try different things before committing them to a function.
Edit: Honestly, I wish they had better screenshots, but this should give you an idea:
Functions: http://www.sqlmanager.net/en/products/postgresql/manager/scr...
Debugging: http://www.sqlmanager.net/en/products/postgresql/manager/scr...
Triggers: http://www.sqlmanager.net/products/postgresql/manager/screen...
Query Builder: (used this much more when I was younger) http://www.sqlmanager.net/en/products/postgresql/manager/scr...
Full list: (though don't know how current) http://www.sqlmanager.net/en/products/postgresql/manager/scr...
The pg docs unfortunately weren't much beyond selecting some data. Trying to write any logic is something that left me struggling (in my case, I needed a hash table that could store a key value pair of numbers).
From my own experience a few years ago, however, go look at the stored procedures in PostGIS. There are many, many of them methodically written and you could probably learn most of what there is to know from detailed inspection.
I'd pay (one upvote) for a blog post with a better way to do this. If one doesn't exist, this might call for a postgres extension.