Re: psql - user defined SQL variables - Mailing list pgsql-general

From David Fetter
Subject Re: psql - user defined SQL variables
Date
Msg-id 20040818054843.GN17886@fetter.org
Whole thread Raw
In response to psql - user defined SQL variables  (Grainne Reilly <greilly1@comcast.net>)
Responses Re: psql - user defined SQL variables  (Grainne Reilly <greilly1@comcast.net>)
List pgsql-general
On Wed, Aug 18, 2004 at 12:22:27AM -0400, Grainne Reilly wrote:
> I am new to PostgreSQL and am porting some scripts written for MySQL
> over to psql.

The least work you'll do here is to refactor your app entirely.

PostgreSQL will just plain handle about 3/4 of what you used to have
to deal with up in middleware land.  It also supports all kinds of
wizardry that will astound you as you run across it. :)

> There is one MySQL feature which I cannot find in psql - user
> defined SQL variables. In MySQL I can use these to hold the result
> (numeric, string or null) of a select: e.g.  select @count =
> count(*) from mytable;

This is a MySQLism to work around their lack of subselects.  But if
that turns out not to be enough, you have a broad choice of procedural
languages, from the ADA-like PL/PgSQL to PL/Perl, PL/Python and (soon)
PL/PHP.

> Thanks in advance for any suggestions,

See about redoing your app.  It will be less work than trying to graft
the MySQL design onto PostgreSQL, which is about like trying to hook
an ox cart to a jet engine :)

Cheers,
D
--
David Fetter david@fetter.org http://fetter.org/
phone: +1 510 893 6100   mobile: +1 415 235 3778

Remember to vote!

pgsql-general by date:

Previous
From: Tino Wildenhain
Date:
Subject: Re: psql - user defined SQL variables
Next
From: Paramveer.Singh@trilogy.com
Date:
Subject: Re: exception handling support in pgSQL