Project

General

Profile

1
#!/bin/bash
2

    
3
#echo Content-type: text/plain
4
#echo ""
5

    
6
## Creating a realized view for analysis from Data Warehouse, a single useful table of specimen records plus plot abundances
7
## 22 May 2010 at NCEAS server Nimoy
8
## Executed June 2011 from /home/condit at Nimoy
9
## ./CreateViews.bat bien2 100000 both condit darter329  (100000 entries for testing)
10
## ./CreateViews.bat bien2 0 both condit darter329       (full table)
11

    
12

    
13
db=$1
14
rows=$2
15
addindex=$3
16
user=$4
17
pwd=$5
18

    
19
if [ -z $rows ]
20
 then  
21
   echo "Create viewFullOccurrence table"
22
   echo "first argument: database"
23
   echo "second: number of rows for testing; enter 0 for full table"
24
   echo "third argument: no to create table without indices; yes to add indices without creating table; both to do both"
25
   echo "fourth: mysql user"
26
   echo "last: password"
27
   exit
28
fi
29

    
30
locktb="LOCK TABLES viewFullOccurrence WRITE, 
31
                    IndividualObservation AS IO WRITE, 
32
                    ObservationSpecimen AS OS WRITE, 
33
                    TaxonDimension AS TD WRITE, 
34
                    SpecimenSourceData AS SSD WRITE, 
35
                    PlotAggregateFact AS PAF WRITE, 
36
                    PlotMetaDataDimension AS PMD WRITE, 
37
                    PlotTimeDimension AS PTD WRITE,
38
                    geoPlotMetaDataDimension AS gPMDD WRITE, 
39
                    geoIndividualObservation AS gIO WRITE;"
40
mysql -u "$user" -p"$pwd" --database="$db" --execute="$locktb"
41
# echo $locktb
42
 
43
if [ $addindex != "yes" ] 
44
  then
45
   mysql -u "$user" -p"$pwd" --database="$db" --execute="CALL CreateView($rows,0);"
46
fi
47

    
48
if [ $addindex != "no" ] 
49
 then
50
   mysql -u "$user" -p"$pwd" --database="$db" --execute="CALL AddViewIndex();"
51
fi
52

    
53
# These could depend on command-line arguments as well
54
mysql -u "$user" -p"$pwd" --database="$db" --execute="CALL CorrectPctCover;"
55
# mysql -u "$user" -p"$pwd" --database="$db" --execute="CALL CTFSFamily;"
56

    
57
mysql -u "$user" -p"$pwd" --database="$db" --execute="UNLOCK tables;"
58

    
59

    
60

    
(4-4/4)