#!/bin/sh

bin_dir=`dirname $0`
def_num_recs=10
db_name=testdb
table="person(id, name, yob)"
dml_file=$bin_dir/makeData.sql
min_yob=1970
min_id=0;

make_dml_script ()
{
# param1 = num recs, param2 = script file
	
  if [ -z "$1" ]
  then
	  num_rec=$def_num_recs
  else
	  num_rec=$1
  fi

  if [ -z "$2" ]
  then
	  script_file=$dml_file
  else
	  script_file=$2
  fi

  echo 
  
  # remove existing file
  if [ -e "$script_file" ]
  then
    rm -f $script_file
  fi

  # put insert statements
  for ((i = 1; i <= num_rec; i++))
  do
	  yob=$((i + min_yob))
	  id=$((i + min_id))
	  echo "INSERT INTO $table VALUES($id, 'person_$id', $yob);" >> $script_file
  done

  return 0
}

#test
#make_dml_script 10 $dml_file

