Re: [GENERAL] User defined function
От | greg@proterians.net |
---|---|
Тема | Re: [GENERAL] User defined function |
Дата | |
Msg-id | Pine.LNX.4.05.9910151625370.22928-100000@proterians.net обсуждение исходный текст |
Ответ на | User defined function ("Moray McConnachie" <moray.mcconnachie@computing-services.oxford.ac.uk>) |
Список | pgsql-general |
> I need to write a function to return the first of december of the year > previous to the current year. Part of my problem is I'm not sure how > to escape quotes in function definitions. I am looking at something > along the lines of > > CREATE FUNCTION startofregyear(date) RETURNS date AS ' > SELECT text_datetime('01/12/' �� float8_text(datepart('year',$1)-1)) > AS answer; > ' LANGUAGE 'SQL'; > > but clearly this won't work because of the large number of single > quotes. I've tried escaping the quotes in the SELECT line with > backslashes, but that doesn't seem to do it. > > Can anyone tell me if this function should work, once I sort out the > escaping? > try using double quotas... CREATE FUNCTION startofregyear(date) RETURNS date AS ' SELECT text_datetime(''01/12/'' float8_text(datepart(''year'',$1)-1)) AS answer; ' LANGUAGE 'SQL'; It should work... --Greg--
В списке pgsql-general по дате отправления: