From: | "Mikhail V(dot) Majorov" <mik(at)ttn(dot)ru> |
---|---|
To: | Richard Huxton <dev(at)archonet(dot)com> |
Cc: | mik(at)nix(dot)org(dot)ru, pgsql-general(at)postgresql(dot)org |
Subject: | Re: function likes sprintf |
Date: | 2001-02-16 13:56:20 |
Message-ID: | 3A8D3184.432DF4DA@ttn.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Richard Huxton wrote:
>
> From: "Mikhail V. Majorov" <mik(at)ttn(dot)ru>
>
> > Hi all!
> >
> > Do pgsql function like sprintf() in C?
> > I write trigger function using plpgsql.
> >
> > This my code:
> > sqlcommand := textcat(''CREATE USER '',NEW.usename);
> > sqlcommand := textcat(sqlcommand, ''WITH SYSID '');
> > sqlcommand := textcat(sqlcommand, NEW.id);
> > sqlcommand := textcat(sqlcommand, ''WITH PASSWORD '');
> > sqlcommand := textcat(sqlcommand, passwd);
> > INSERT INTO todo_surep_user VALUES (sqlcommand, now(), '''');
> >
> > How do I replace "textcat" on another construct of language?
>
> You can use the || operator such as:
>
> sqlcommand := "CREATE USER " || NEW.usename || "WITH SYSID" ...
>
> If you are after the more advanced formatting %7.3f stuff you'll need to
> look at the various procedural languages (pltcl,plperl) - you could write
> you own function to emulate sprintf but I don't think the interface supports
> a variable number of parameters.
Thanks for guess.
I use plpgsql becase this language permit to use SQL command.
As I undestand I can't use SQL command from plperl or pltcl. Is it
right?
Mik.
From | Date | Subject | |
---|---|---|---|
Next Message | Mike Mascari | 2001-02-16 13:58:03 | RE: Triggers and RI-style behavior. |
Previous Message | Mike Mascari | 2001-02-16 13:28:56 | Triggers and RI-style behavior. |