Re: How can I use parameters in plain sql

From: Cédric Villemain <cedric(dot)villemain(dot)debian(at)gmail(dot)com>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: John Adams <john_adams_mail(at)yahoo(dot)com>, PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: How can I use parameters in plain sql
Date: 2010-09-05 15:37:48
Message-ID: AANLkTinjUkLdBkF74X6ermx5AsOcdyuqT5EyuLZ+f1g0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2010/9/3 Merlin Moncure <mmoncure(at)gmail(dot)com>:
> On Fri, Sep 3, 2010 at 3:47 PM, John Adams <john_adams_mail(at)yahoo(dot)com> wrote:
>>> psql has some client side manged variables, and you can of course use
>>> pl/pgsql.
>> Do you mean I should use a pl/pgsql stored procedure or do I have to somehow
>> mark the sql as pl/pgsql? How?
>> Because in sql server it is all the same i.e. plain sql=tsql
>
> pl/pgsql is only used in functions:
>
> create function foo(i int) returns setof mytable as
> $$
> begin
>  return query select * from mytable where id = i;
> end;
> $$ language plpgsql;
>
> then
>
>
> plpgsql is reserved for fancy things that are tricky to do with plain
> sql.  it's got loops, robust error handling, etc.
>
> http://www.postgresql.org/docs/8.4/static/plpgsql.html
>

Also, in PostgreSQL 9.0 you can have anonymous code blocks with 'DO'.
http://www.postgresql.org/docs/9.0/static/sql-do.html

--
Cédric Villemain               2ndQuadrant
http://2ndQuadrant.fr/     PostgreSQL : Expertise, Formation et Support

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2010-09-05 19:46:57 Re: Vacuum full progress
Previous Message Tom Lane 2010-09-05 15:30:44 Re: does record_eq() ignore user-defined operators?