Port "use_tunneled_reply" fix for MS-CHAP from branch_1_1
[freeradius.git] / dialup_admin / sql / oracle / mtotacct.sql
1 /*
2  * $Id$
3  *
4  */
5
6
7 /*
8  * Table structure for table 'mtotacct'
9  */
10 CREATE TABLE mtotacct (
11         mtotacctid      INT PRIMARY KEY,
12         username        varchar(64) DEFAULT '' NOT NULL,
13         acctdate        DATE DEFAULT sysdate NOT NULL,
14         connnum         NUMERIC(12),
15         conntotduration NUMERIC(12),
16         connmaxduration NUMERIC(12),
17         connminduration NUMERIC(12),
18         inputoctets     NUMERIC(12),
19         outputoctets    NUMERIC(12),
20         nasipaddress    varchar(15) default NULL
21 );
22
23 CREATE INDEX mtotacct_acctdate_idx ON mtotacct (acctdate);
24 CREATE INDEX mtotacct_nasipaddress_idx ON mtotacct (nasipaddress);
25 CREATE INDEX mtotacct_username_idx ON mtotacct (username);
26 CREATE INDEX mtotacct_userondate_idx ON mtotacct (username, acctdate);
27
28 CREATE SEQUENCE mtotacct_seq START WITH 1 INCREMENT BY 1;
29
30 /* Trigger to emulate a serial # on the primary key */
31 CREATE OR REPLACE TRIGGER mtotacct_serialnumber
32         BEFORE INSERT OR UPDATE OF mtotacctid ON mtotacct
33         FOR EACH ROW
34         BEGIN
35                 if ( :new.mtotacctid = 0 or :new.mtotacctid is null ) then
36                         SELECT mtotacct_seq.nextval into :new.mtotacctid from dual;
37                 end if;
38         END;
39 /
40