Skip site navigation (1) Skip section navigation (2)

Re: proof concept: do statement parametrization

From: Florian Pflug <fgp(at)phlo(dot)org>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proof concept: do statement parametrization
Date: 2010-07-04 07:59:40
Message-ID: E84DB895-2FA0-430E-9F8F-472508BFB5DF@phlo.org (view raw or flat)
Thread:
Lists: pgsql-hackers
On Jul4, 2010, at 08:41 , Pavel Stehule wrote:
> I enhanced DO statement syntax to allowing a parameters. Syntax is
> relative simple:
> 
> do ([varname] vartype := value, ...) $$ ... $$


I think it'd be more useful to put the values at the very end of the statement, not somewhere in the middle. For positional parameters I envision

do (vartype, ...) $$ ... $$ using value, ...

and for named parameters it'd be

do (varname vartype) $$ ... $$ using varname := value, ...

I won't make a difference for your use-case, but it'd make it easier to call the same DO block with different parameters, like in the following shell  snippet.

COMMANDS="DO (arg int) $$ ... $$"
(for a in arg1, arg2, arg3, arg4; do
  echo "$COMMANDS USING $a;"
done) | psql 

best regards,
Florian Pflug


In response to

Responses

pgsql-hackers by date

Next:From: Pavel StehuleDate: 2010-07-04 09:59:36
Subject: Re: proof concept: do statement parametrization
Previous:From: Rainer PruyDate: 2010-07-04 07:40:06
Subject: Re: pessimal trivial-update performance

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group