CREATE OR REPLACE FUNCTION INITTABLE() RETURNS void AS $$
DECLARE
BEGIN
     DELETE FROM ADDRESS;
     INSERT INTO ADDRESS ( CUSTOMER_CODE, CUSTOMER_NAME, 
                      POST_CODE    , CUSTOMER_ADDRESS, 
                      CUSTOMER_TEL ) 
       VALUES(  '00000001',	
           'terasoluna1',
           '111-1234',
           '搶嫗搒拞墰嬫',
           '000-1234-1234');
     INSERT INTO ADDRESS ( CUSTOMER_CODE, CUSTOMER_NAME, 
                      POST_CODE    , CUSTOMER_ADDRESS, 
                      CUSTOMER_TEL ) 
       VALUES(  '00000002', 
           '揷拞',
           '222-1234',
           '搶嫗搒拞墰嬫',
           '111-4567-8901');
          
     INSERT INTO ADDRESS ( CUSTOMER_CODE, CUSTOMER_NAME, 
                      POST_CODE    , CUSTOMER_ADDRESS, 
                      CUSTOMER_TEL ) 
       VALUES(  '00000003', 
           '楅栘',
           '333-1234',
           '搶嫗搒拞墰嬫',
           '123-4567-1234');

     INSERT INTO ADDRESS ( CUSTOMER_CODE, CUSTOMER_NAME, 
                      POST_CODE    , CUSTOMER_ADDRESS, 
                      CUSTOMER_TEL ) 
       VALUES(  '00000004',
           '崅嫶',
           '444-1234',
           '愮梩導惉揷巗',
           '111-4567-8901');
           
     INSERT INTO ADDRESS ( CUSTOMER_CODE, CUSTOMER_NAME, 
                      POST_CODE    , CUSTOMER_ADDRESS, 
                      CUSTOMER_TEL ) 
       VALUES(  '00000005', 
           '彫抮',
           '555-1234',
           '搶嫗搒拞墰嬫',
           '123-4567-1234');
           
INSERT INTO ADDRESS ( CUSTOMER_CODE, CUSTOMER_NAME, 
                      POST_CODE    , CUSTOMER_ADDRESS, 
                      CUSTOMER_TEL ) 
  VALUES(  '00000006', 
           '楅栘',
           '666-1234',
           '搶嫗搒懌棫嬫',
           '000-1234-1234');
           
INSERT INTO ADDRESS ( CUSTOMER_CODE, CUSTOMER_NAME, 
                      POST_CODE    , CUSTOMER_ADDRESS, 
                      CUSTOMER_TEL ) 
  VALUES(  '00000007', 
           '嵅摗',
           '777-1234',
           '搶嫗搒崙棫巗',
           '111-4567-8901');
           
INSERT INTO ADDRESS ( CUSTOMER_CODE, CUSTOMER_NAME, 
                      POST_CODE    , CUSTOMER_ADDRESS, 
                      CUSTOMER_TEL ) 
  VALUES(  '00000008', 
           '惵栘',
           '888-1234',
           '搶嫗搒廰扟嬫',
           '123-4567-1234');
 
INSERT INTO ADDRESS ( CUSTOMER_CODE, CUSTOMER_NAME, 
                      POST_CODE    , CUSTOMER_ADDRESS, 
                      CUSTOMER_TEL ) 
  VALUES(  '00000009', 
           '嶳杮',
           '999-1234',
           '搶嫗搒拞栰嬫',
           '111-4567-8901');
           
INSERT INTO ADDRESS ( CUSTOMER_CODE, CUSTOMER_NAME, 
                      POST_CODE    , CUSTOMER_ADDRESS, 
                      CUSTOMER_TEL ) 
  VALUES(  '00000010', 
           '嶳壓',
           '000-1234',
           '搶嫗搒嶰戦巗',
           '123-4567-1234');
           
END;
$$ LANGUAGE plpgsql;
COMMIT;

CREATE OR REPLACE FUNCTION INITIALDB() RETURNS void AS $$
DECLARE
BEGIN
     PERFORM INITTABLE();
     DELETE FROM CODELIST;
     insert into CODELIST values ( '1','DATABASE僐乕僪儕僗僩侾');
     insert into CODELIST values ( '2','DATABASE僐乕僪儕僗僩俀');
     insert into CODELIST values ( '3','DATABASE僐乕僪儕僗僩俁');
     insert into CODELIST values ( '4','DATABASE僐乕僪儕僗僩係');
     insert into CODELIST values ( '5','DATABASE僐乕僪儕僗僩俆');
     DELETE FROM TUSER;
     INSERT INTO TUSER (USER_CODE, USER_NAME, USER_PASSWORD, USER_DIVISION) VALUES ('00000001', 'terasoluna', 'password', '0');
     INSERT INTO TUSER (USER_CODE, USER_NAME, USER_PASSWORD, USER_DIVISION) VALUES ('00000002', 'admin', 'password', '0');
     INSERT INTO TUSER (USER_CODE, USER_NAME, USER_PASSWORD, USER_DIVISION) VALUES ('00000003', 'maeda', 'password', '1');
     INSERT INTO TUSER (USER_CODE, USER_NAME, USER_PASSWORD, USER_DIVISION) VALUES ('00000004', 'kimura', 'password', '1');
     
END;
$$ LANGUAGE plpgsql;
COMMIT;
