Project

General

Profile

1 10084 aaronmk
SELECT util.search_path_append('util');
2 8163 aaronmk
3 8184 aaronmk
SELECT set_col_types('"COND"', ARRAY[
4 10054 aaronmk
  ('*STATECD', 'integer')
5
, ('*UNITCD', 'integer')
6
, ('*COUNTYCD', 'integer')
7 8172 aaronmk
, ('locationName', 'integer')
8 10054 aaronmk
, ('*INVYR', 'integer')
9 8172 aaronmk
, ('authorEventCode', 'integer')
10 8184 aaronmk
]::col_cast[]);
11 8110 aaronmk
12 8192 aaronmk
SELECT mk_derived_col(('"COND"', 'oldGrowth'), $$
13 8100 aaronmk
(
14 10054 aaronmk
    "*COND-STDAGE"::integer>80
15
    AND ("*COND-TRTCD1"='0' OR "*COND-TRTCD1" IS NULL)
16
    AND (("*COND-DSTRBCD1"<>'30' AND "*COND-DSTRBCD1"<>'31' AND "*COND-DSTRBCD1"<>'32' AND "*COND-DSTRBCD1"<>'80') OR "*COND-DSTRBCD1" IS NULL)
17
    AND ("*COND-STUMP_CD_PNWRS"='N' OR "*COND-STUMP_CD_PNWRS" IS NULL)
18
    AND "*COND-HARVEST_TYPE1_SRS" IS NULL
19
    AND "*COND-PRESNFCD" IS NULL
20
    AND ("*COND-STDORGCD"='0' OR "*COND-STDORGCD" IS NULL)
21 8100 aaronmk
)
22 10054 aaronmk
OR "*COND-STND_COND_CD_PNWRS"='7'
23 8100 aaronmk
$$);
24
25 10054 aaronmk
SELECT create_if_not_exists($$ALTER TABLE "COND" ADD CONSTRAINT "COND.ID"     UNIQUE ("*COND-CN")$$);
26
SELECT create_if_not_exists($$ALTER TABLE "COND" ADD CONSTRAINT "COND.unique" UNIQUE ("*STATECD", "*UNITCD", "*COUNTYCD", "locationName", "*INVYR", "authorEventCode")$$);
27 8184 aaronmk
SELECT cluster_once('"COND"', '"COND.unique"');