Re: [GENERAL] User defined function

From: Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il>
To: "Moray McConnachie" <moray(dot)mcconnachie(at)computing-services(dot)oxford(dot)ac(dot)uk>, <greg(at)proterians(dot)net>
Cc: <pgsql-general(at)postgreSQL(dot)org>
Subject: Re: [GENERAL] User defined function
Date: 1999-10-17 16:52:58
Message-ID: l03130304b42faca8a73a@[147.233.159.109]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

At 16:41 +0200 on 15/10/1999, Moray McConnachie wrote:

> absolutely not, I tried that already.
> I get "attribute not found" error wherever the opening double-quotes
> are during the create of the function.

Not double quotes (The character "), but two single quotes one after the other.

Anyway, I would take a wholly different approach to this. I don't like
manipulating text and relying on the date format. I prefer working only
with dates and times. So I would use something like this:

testing=> CREATE FUNCTION dec_first( date ) RETURNS date as '
testing'> SELECT date( date_trunc( ''year'', $1 ) - ''1 month''::timespan )'
testing-> LANGUAGE 'sql';
CREATE
testing=> select dec_first('1980-08-14');
dec_first
----------
12-01-1979
(1 row)

testing=> select dec_first('1996-08-15');
dec_first
----------
12-01-1995
(1 row)

testing=> select dec_first('2004-02-14');
dec_first
----------
12-01-2003
(1 row)

Note how my doubled-quotes worked well?

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jim Cromie 1999-10-18 00:51:21 Re: XQL Problems
Previous Message root 1999-10-17 15:50:45 SP are good, but ....