Re: sql insert function - Mailing list pgsql-general

From Richard Huxton
Subject Re: sql insert function
Date
Msg-id 200401131137.45092.dev@archonet.com
Whole thread Raw
In response to Re: sql insert function  (Doug McNaught <doug@mcnaught.org>)
List pgsql-general
On Tuesday 13 January 2004 00:35, Doug McNaught wrote:
> "Chris Ochs" <chris@paymentonline.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

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: qq- repost
Next
From: Richard Huxton
Date:
Subject: Re: sql insert function