Project

General

Profile

1
SELECT util.search_path_append('util');
2

    
3
SELECT set_col_types('"COND"', ARRAY[
4
  ('*STATECD', 'integer')
5
, ('*UNITCD', 'integer')
6
, ('*COUNTYCD', 'integer')
7
, ('locationName', 'integer')
8
, ('*INVYR', 'integer')
9
, ('authorEventCode', 'integer')
10
]::col_cast[]);
11

    
12
SELECT mk_derived_col(('"COND"', 'oldGrowth'), $$
13
(
14
    "*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
)
22
OR "*COND-STND_COND_CD_PNWRS"='7'
23
$$);
24

    
25
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
SELECT cluster_once('"COND"', '"COND.unique"');
(7-7/10)