From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Vincenzo Romano <vincenzo(dot)romano(at)notorand(dot)it> |
Cc: | PostgreSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: [WISHLIST] EXECUTE SPRINTF |
Date: | 2010-07-16 18:59:22 |
Message-ID: | AANLkTiksA4N1TT85FgwxwQV5JBuVlvnN4erZf5i6uaCr@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
2010/7/16 Vincenzo Romano <vincenzo(dot)romano(at)notorand(dot)it>:
> Hi all.
> I'd like to add an item to the PG wishlist (provided that one exists).
> In PL/PgSQL function bodies I'm using very often a pattern like this:
>
> EXECUTE SPRINTF( '...',... );
>
> Where SPRINFT comes from here:
> http://wiki.postgresql.org/wiki/Sprintf
>
> It's by far more powerful, easy and effective than the standard
> "string concatenation" mechanism available for the plain EXECUTE.
> It's a different approach than the EXECUTE ... USING which has it's
> own rules and limitations (see chapter 38.5.4 for v8.4.4).
> The proposed approach doesn't know anything about symbols or other PL/PGSQL
> related syntax and can be used to build very complex (or otherwise
> impossible) dynamic SQL.
>
> I'd like to either see the SPRINTF function embedded either into the
> language, possibly with really variadic argument list (like stdarg.h
> in C) or into the EXECUTE itself with something like "EXECUTE <a
> string> SPRINTF <argument list>".
>
> Does this make any sense to you all?
Current commitfest has a patch for functions format (in core) and
sprintf (in contrib). So in next version you will can do some like
EXECUTE format('INSERT INTO % (a,b) VALUES($1,$2)', quote_ident(tab))
USING val1, val2;
Regards
Pavel Stehule
>
> --
> Vincenzo Romano
> NotOrAnd Information Technologies
> NON QVIETIS MARIBVS NAVTA PERITVS
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
From | Date | Subject | |
---|---|---|---|
Next Message | Joshua Rubin | 2010-07-16 19:05:37 | Re: Efficient Way to Merge Two Large Tables |
Previous Message | Tom Lane | 2010-07-16 17:14:25 | Re: Full Text Search dictionary issues |