From: | Doug McNaught <doug(at)mcnaught(dot)org> |
---|---|
To: | "Matthew Nuzum" <cobalt(at)bearfruit(dot)org> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: quoting and EXECUTE in plpgsql function |
Date: | 2002-11-04 02:36:47 |
Message-ID: | m3wunu2h8g.fsf@varsoon.wireboard.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"Matthew Nuzum" <cobalt(at)bearfruit(dot)org> writes:
> Hello, I'm writing my first large plpgsql function and I'm having a
> little difficulty.
>
> First, let me say that I'm editing my function through phpPgAdmin, and I
> believe that it requires you to escape all single quotes when entering
> functions. I'm not sure if that is also true when creating a function
> using the command line tools.
Yes.
> EXECUTE '' INSERT INTO raw_data '' ||
Any reason you're using EXECUTE here? EXECUTE is really only needed
when the table or column names need to be determined at runtime. Your
query looks quite normal, so you don't need to use EXECUTE. As a
bonus, the query will get compiled and the plan saved so you won't be
calling the planner for every row you insert.
Second, I don't think you need quote_ident, especially if you're not
using EXECUTE.
You should just be able to do something like:
INSERT INTO foo_table (bar, baz, quux) VALUES (bar, baz, quux);
(assuming bar, baz and quux are aliased in your declaration section.
Give that a try.
-Doug
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-11-04 02:39:04 | Re: quoting and EXECUTE in plpgsql function |
Previous Message | Matthew Nuzum | 2002-11-04 02:25:58 | quoting and EXECUTE in plpgsql function |