#!/bin/tcsh -ef
if ("$1" == "") then
    echo "error: no table name specified"
    exit 1
endif
if ("$jdb" == "") then
    echo "env var jdb not set.  should be something like jackson20060125"
    exit 1
endif
set table = "$1"
set outpath = "/san/sanvol1/visiGene/offline/jax/$jdb"

#create table in jackson db
hgsql $jdb -e "source $outpath/${table}.sql"

#load rows
hgsql $jdb -e "SET max_error_count=24000000;load data local infile '${outpath}/${table}.tab' into table ${table};show warnings" > ${outpath}/${table}.err

if ( -s ${outpath}/${table}.err ) then
    head ${outpath}/${table}.err
    echo "[...]"
    echo ""
    #exit 1  # can't exit 1 err for now, because some errs are definitely bogus
endif

#save space
#rm -f $table.tab
	
