Re: sql insert function

From: Richard Huxton <dev(at)archonet(dot)com>
To: Doug McNaught <doug(at)mcnaught(dot)org>, "Chris Ochs" <chris(at)paymentonline(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: sql insert function
Date: 2004-01-13 11:37:45
Message-ID: 200401131137.45092.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tuesday 13 January 2004 00:35, Doug McNaught wrote:
> "Chris Ochs" <chris(at)paymentonline(dot)com> writes:
> >
> > CREATE FUNCTION taxship(varchar,integer,varchar,float,float) returns
> > integer AS '
> > insert into taxship(s_oid,order_id,mer_id,tax,shipping) values
> > ('$1',$2,'$3',$4,$5);
> > SELECT 1;
> > ' LANGUAGE SQL;
>
> When you want to use single quotes inside a quoted string (which is
> what a function body is) you need to escape them.

Can I point out that you don't need any quotes here - these are variables not
literals. Just do:

INSERT INTO (...) VALUES ($1,$2,$3...)

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2004-01-13 11:38:51 Re: sql insert function
Previous Message Richard Huxton 2004-01-13 11:28:09 Re: qq- repost