From 393a50f1f6f5bd3151d9eb2e9a64bb602a9a4534 Mon Sep 17 00:00:00 2001 From: pnixon Date: Fri, 18 Mar 2005 22:25:10 +0000 Subject: [PATCH] mtotacct for Oracle --- sql/oracle/mtotacct.sql | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 sql/oracle/mtotacct.sql diff --git a/sql/oracle/mtotacct.sql b/sql/oracle/mtotacct.sql new file mode 100644 index 0000000..7067b70 --- /dev/null +++ b/sql/oracle/mtotacct.sql @@ -0,0 +1,40 @@ +/* + * $Id$ + * + */ + + +/* + * Table structure for table 'mtotacct' + */ +CREATE TABLE mtotacct ( + mtotacctid INT PRIMARY KEY, + username varchar(64) NOT NULL, + acctdate DATE, + connnum NUMERIC(12), + conntotduration NUMERIC(12), + connmaxduration NUMERIC(12), + connminduration NUMERIC(12), + inputoctets NUMERIC(12), + outputoctets NUMERIC(12), + nasipaddress varchar(15) default NULL +); + +CREATE INDEX mtotacct_acctdate_idx ON mtotacct (acctdate); +CREATE INDEX mtotacct_nasipaddress_idx ON mtotacct (nasipaddress); +CREATE INDEX mtotacct_username_idx ON mtotacct (username); +CREATE INDEX mtotacct_userondate_idx ON mtotacct (username, acctdate); + +CREATE SEQUENCE mtotacct_seq START WITH 1 INCREMENT BY 1; + +/* Trigger to emulate a serial # on the primary key */ +CREATE OR REPLACE TRIGGER mtotacct_serialnumber + BEFORE INSERT OR UPDATE OF mtotacctid ON mtotacct + FOR EACH ROW + BEGIN + if ( :new.mtotacctid = 0 or :new.mtotacctid is null ) then + SELECT mtotacct_seq.nextval into :new.mtotacctid from dual; + end if; + END; +/ + -- 2.39.5