Re: sql insert function

From: Doug McNaught <doug(at)mcnaught(dot)org>
To: "Chris Ochs" <chris(at)paymentonline(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: sql insert function
Date: 2004-01-13 00:35:53
Message-ID: 878ykc65xy.fsf@asmodeus.mcnaught.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Chris Ochs" <chris(at)paymentonline(dot)com> writes:

> The documentation doesn't have any examples of using an sql language
> function to do an insert, andI am at loss as to I am doing wrong here.
> The error I get trying to create the function is: ERROR: syntax error at
> or near "$1" at character 148
>
> 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.

-Doug

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thapliyal, Deepak 2004-01-13 00:40:34 Parse error help needed...
Previous Message Richard Welty 2004-01-13 00:35:43 Re: sql insert function