Moved unused and unneeded stored procedure to a separate file
[freeradius.git] / doc / examples / postgresql.sql.extra
1 /*
2  * $Id$
3  *
4  * Postgresql extra schema for FreeRADIUS
5  *
6  * Note: (pnixon: 2003-12-10) The following function should not be required
7  * if you use the PG specific queries in raddb/postgresql.conf
8  *
9  * Common utility function for date calculations. This is used in our
10  * alternative account stop query to calculate the start of a session.
11  *
12  * This function is Copyright 2001 by Mark Steele (msteele@inet-interactif.com)
13  *
14  * Please note that this requires the plpgsql to be available in your
15  * radius database. If it is not available you can register it with
16  * postgres by running this command:
17  *
18  *   createlang plpgsql <databasename>
19  */
20 CREATE FUNCTION DATE_SUB(date,int4,text) RETURNS DATE AS '
21 DECLARE
22         var1 date;
23         var2 text;
24 BEGIN
25         var2 = $2 || '' '' || $3;
26         SELECT INTO var1
27                 to_date($1 - var2::interval, ''YYYY-MM-DD'');
28 RETURN var1;
29 END;' LANGUAGE 'plpgsql';