Re: Creating a function with single quotes
От | Leif B. Kristensen |
---|---|
Тема | Re: Creating a function with single quotes |
Дата | |
Msg-id | 200902201513.03872.leif@solumslekt.org обсуждение исходный текст |
Ответ на | Creating a function with single quotes (Shawn Tayler <stayler@washoecounty.us>) |
Список | pgsql-sql |
On Friday 20. February 2009, Shawn Tayler wrote: >Hello Jasen and the List, > >I tried the $$ quote suggestion: > >create function f_csd_interval(integer) returns interval as >$$ >BEGIN >RETURN $1 * interval '1 msec' >END; >$$ >LANGUAGE 'plpgsql'; > >Here is what I got: > >edacs=# \i 'f_csd_interval.sql' >psql:f_csd_interval.sql:7: ERROR: syntax error at or near "END" >LINE 1: SELECT ( $1 * interval '1 msec') END > ^ >QUERY: SELECT ( $1 * interval '1 msec') END >CONTEXT: SQL statement in PL/PgSQL function "f_csd_interval" near > line2 edacs=# > >The error at or near END is curious. There must be something wrong in >the line before it but I can't see it. Suggestions? You should place a semicolon at the end of the RETURN line, and remove the one after END, BTW, simple functions as this are better written in the SQL language. I can't speak for the validity of the code itself, but you can rewrite it as create function f_csd_interval(integer) returns interval as $$ SELECT $1 * interval '1 msec' $$ LANGUAGE SQL; -- Leif Biberg Kristensen | Registered Linux User #338009 Me And My Database: http://solumslekt.org/blog/
В списке pgsql-sql по дате отправления: