views:

166

answers:

2

With SQL Server, I can execute code ad hoc T-SQL code with full procedural logic through SQL Server Management Studio, or any other client. I've begun working with PostgreSQL and have run into a bit of a difference in that PGSQL requires any logic to be embedded in a function.

Is there a way to execute PL/PGSQL code without creating an executing a function?

+2  A: 

No, not yet. Version 9.0 (still alpha) will have this option (do), you a have to wait until it's released.

Frank Heikens
+1, but I think it was announced for 8.5 - http://developer.postgresql.org/pgdocs/postgres/release-8.5.html
Michael Krelin - hacker
I thought that 8.5 became 9.0 because of some major features that were implemented...
Jeremiah Peschka
Ah, that would explain it.
Michael Krelin - hacker
Yep, 8.5 became 9.0. DO works very nice, just download the alpha and start testing: http://www.postgresql.org/download/snapshots
Frank Heikens
Frank, wish I knew where to download time to play with 9.0 ;-)
Michael Krelin - hacker
+1  A: 

Postgres 9

DO $$ select * from foo; $$
chotchki