Thursday, December 16, 2010

PL/pgSQL dabbling for free



If you do not have a PostgreSQL server available to dabble with, and you wish to do some learning by experimentation, free database accounts are available at Rdbhost.com.

These databases are accessible through a small variety of APIs, but the straightforward way for our purposes is to use the on-site admin tool, RdbAdmin.

Let's walk through the process of creating a new database on Rdbhost, and trying some simple PL/pgSQL functions there.

Visit http://www.rdbhost.com.  Provide your email address in the 'Make Me a Database' form, skim the terms of service, click the box acknowledging them, and submit.




Rdbhost will email you a registration letter, which you should get and read, and copy the password contained therein onto the clipboard.  Return to site, and login:


Upon your first login, the site will create your database, and show you your profile page, resembling this next image.  I recommend that, at this point, you change the password to something memorable to you, so that you can easily login in the future.:


Click the 'Rdbadmin' link to open the RdbAdmin app:



The 'SQL Command' button will open an edit box for the entry of SQL and PL/pgSQL commands:


Enter an SQL or PL/pgSQL query and click the 'Execute' button.  Results of your query will appear above the edit box:



If you enter a syntax error into your PL/pgSQL, PostgreSQL will issue an error message, and RdbAdmin will display it like this:


You will likely need data tables to experiment with before you go too far, and such tables can be created a couple of ways.  First, you can just write the raw CREATE TABLE SQL into the SQL edit field, or you can use the Create Table feature:


There are features to assist in creating views, schemata, and indexes as well, but none yet for creating functions or triggers.  Use the SQL edit box to create functions using the raw SQL; after all, we are here to exercise our PL/pgSQL writing abilities are we not?

Next week, I will show how to create and return a table record with a PL/pgSQL function.

No comments:

Post a Comment