--
-- Table to group recv's into



CREATE SEQUENCE recvgrpland_id_seq
  INCREMENT 1
  MINVALUE 1
  MAXVALUE 2147483647
  START 1
  CACHE 1;
ALTER TABLE recvgrpland_id_seq
  OWNER TO admin;
GRANT ALL ON TABLE recvgrpland_id_seq TO admin;
GRANT ALL ON TABLE recvgrpland_id_seq TO xtrole;



CREATE TABLE recvgrpland
(

    recvgrpland_id integer NOT NULL DEFAULT nextval(('recvgrpland_id_seq'::text)::regclass),
    recvgrpland_vohead_id INTEGER,
      recvgrpland_recvgrp_id INTEGER,
    recvgrpland_curr_id INTEGER,
    recvgrpland_cost numeric(12,4) DEFAULT 0.0,
    recvgrpland_method TEXT DEFAULT 'Q',
    recvgrpland_glseries INTEGER DEFAULT 0,
  
  CONSTRAINT recvgrpland_pkey PRIMARY KEY (recvgrpland_id )
)
WITH (
  OIDS=FALSE
);
ALTER TABLE recvgrpland
  OWNER TO admin;
GRANT ALL ON TABLE recvgrpland TO admin;
GRANT ALL ON TABLE recvgrpland TO xtrole;
COMMENT ON TABLE recvgrpland
  IS 'Map of landed costs to received group';
  
  

ALTER TABLE recvgrpland ADD CONSTRAINT recvgrpland_vohead_id_fkey FOREIGN KEY (recvgrpland_vohead_id)
        REFERENCES vohead(vohead_id) MATCH SIMPLE
      ON UPDATE CASCADE ON DELETE NO ACTION;  

ALTER TABLE recvgrpland ADD CONSTRAINT recvgrpland_recvgrp_id_fkey FOREIGN KEY (recvgrpland_recvgrp_id)
        REFERENCES recvgrp(recvgrp_id) MATCH SIMPLE
      ON UPDATE CASCADE ON DELETE NO ACTION;  
 
--CREATE INDEX recv_recvgrp_id_ix  ON recv  USING btree  (recv_recvgrp_id);
 
