/* -------------------------------------------------------------------- 
** NAME         POLDMBLD.SQL - SQL script to create DEPT and EMP demo    
**			      tables against Oracle Lite               
**                                                                      
** NOTES        This file uses native datatypes to create table         
**              definitions. The script MAY NOT BE PORTABLE to other    
**              databases.            			                
**                                                                      
** To use, you must use SQL*Plus as follows:
**
** PLUS80.EXE <username>/<password>@odbc:<odbc_datasource> @<sqlscript> 
**
** eg: plus80 scott/tiger@odbc:POLITE @poldmbld.sql 
**
** MODIFIED 
**      09-JUN-98  cbarrow Adapted for OLite 3.0 and above
**      24-JUN-96  cbarrow				                
**         Created poldmbld.sql from standard Forms demobld.sql script.
*/

/* Write messages to a log file */

SPOOL POLDMBLD.LOG

/* Drop tables */

DROP table EMP;
DROP table DEPT;

/* Create tables */
CREATE TABLE DEPT (
 DEPTNO              NUMBER(2) CONSTRAINT DEPT_PRIMARY_KEY PRIMARY KEY,
 DNAME               varchar2(14),
 LOC                 varchar2(13));


INSERT INTO DEPT VALUES (10,'ACCOUNTING','NEW YORK');
INSERT INTO DEPT VALUES (20,'RESEARCH','DALLAS');
INSERT INTO DEPT VALUES (30,'SALES','CHICAGO');
INSERT INTO DEPT VALUES (40,'OPERATIONS','BOSTON');

commit;	

CREATE TABLE EMP (
 EMPNO               NUMBER(5) CONSTRAINT EMP_PRIMARY_KEY PRIMARY KEY , 
 ENAME               varchar2(10),
 JOB                 varchar2(9),
 MGR                 NUMBER(4) ,
 HIREDATE            DATE,
 SAL                 NUMBER(7,2),
 COMM                NUMBER(7,2),
 DEPTNO              NUMBER(2) NOT NULL CONSTRAINT EMP_FOREIGN_KEY REFERENCES DEPT (DEPTNO));

 /* disable constraint until we have the data in */
/*   alter table emp disable constraint EMP_SELF_KEY;  */

INSERT INTO EMP VALUES (7369,'SMITH','CLERK',7902,'17-DEC-80',800,NULL,20);
INSERT INTO EMP VALUES (7499,'ALLEN','SALESMAN',7698,'20-FEB-81',1600,300,30);
INSERT INTO EMP VALUES (7521,'WARD','SALESMAN',7698,'22-FEB-81',1250,500,30);
INSERT INTO EMP VALUES (7566,'JONES','MANAGER',7839,'2-APR-81',2975,NULL,20);
INSERT INTO EMP VALUES (7654,'MARTIN','SALESMAN',7698,'28-SEP-81',1250,1400,30);
INSERT INTO EMP VALUES (7698,'BLAKE','MANAGER',7839,'1-MAY-81',2850,NULL,30);
INSERT INTO EMP VALUES (7782,'CLARK','MANAGER',7839,'9-JUN-81',2450,NULL,10);
INSERT INTO EMP VALUES (7788,'SCOTT','ANALYST',7566,'09-DEC-82',3000,NULL,20);
INSERT INTO EMP VALUES (7839,'KING','PRESIDENT',NULL,'17-NOV-81',5000,NULL,10);
INSERT INTO EMP VALUES (7844,'TURNER','SALESMAN',7698,'8-SEP-81',1500,NULL,30);
INSERT INTO EMP VALUES (7876,'ADAMS','CLERK',7788,'12-JAN-83',1100,NULL,20);
INSERT INTO EMP VALUES (7900,'JAMES','CLERK',7698,'3-DEC-81',950,NULL,30);
INSERT INTO EMP VALUES (7902,'FORD','ANALYST',7566,'3-DEC-81',3000,NULL,20);
INSERT INTO EMP VALUES (7934,'MILLER','CLERK',7782,'23-JAN-82',1300,NULL,10);

/*   alter table emp enable constraint EMP_SELF_KEY;  */

commit;
  
/* All done								*/

SPOOL OFF;
