Re: prepare in a do loop

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Marc Millas <marc(dot)millas(at)mokadb(dot)com>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: prepare in a do loop
Date: 2021-02-15 16:23:12
Message-ID: 50400553-24b6-47e5-a5e5-3eeb63ae8080@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2/15/21 8:18 AM, Marc Millas wrote:
> Hi,
>
> in psql, with a postgres 12.5 db on a centos 7 intel:
> I do create a function named randname() returning a varchar, and a table
> matable with a column prenom varchar(50). then
> postgres=# prepare moninsert(varchar) as
> postgres-# insert into matable(prenoms) values($1);
> PREPARE
>
> I test it:
> postgres=# execute moninsert(randname());
> INSERT 0 1
>
> up to now, everything fine. then:
> do $$ begin for counter in 1..1000000 loop execute
> moninsert(randname());end loop;end;$$;
> ERREUR:  la fonction moninsert(character varying) n'existe pas
> LIGNE 1 : SELECT moninsert(randname())
>
> someone can explain ?

EXECUTE in plpgsql means something different:

https://www.postgresql.org/docs/12/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN

>
> thanks
>
> (its a french db, so error message in french :-)
>
> Marc MILLAS
> Senior Architect
> +33607850334
> www.mokadb.com <http://www.mokadb.com>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2021-02-15 16:23:26 Re: prepare in a do loop
Previous Message Marc Millas 2021-02-15 16:18:48 prepare in a do loop