#!/bin/bash

# Clean old data
# rasql --user rasadmin --passwd rasadmin --quiet --query "drop collection MemTestData"
# rasdl --delsettype MemTestSet
# rasdl --delmddtype MemTests
# rasdl --delmddtype MemTest

# Insert types
# rasql --user rasadmin --passwd rasadmin --quiet --query "create type MemTest as unsigned short mdarray[x,y]"
# rasql --user rasadmin --passwd rasadmin --quiet --query "create type MemTests as unsigned short mdarray[year(0:*), month(1:12), day(1:31), hour(0:23), minute(0:59), row, col]"
# rasql --user rasadmin --passwd rasadmin --quiet --query "create type MemTestSet as set(MemTests)"
# rasql --user rasadmin --passwd rasadmin --quiet --query "create collection MemTestData MemTestSet"
# rasql --user rasadmin --passwd rasadmin --quiet --query "insert into MemTestData values marray it in [0:0,1:1,1:1,0:0,0:0,0:0,0:0] values 0us"

day=1
while [ $day -le 31 ]
do
  hour=0
  while [ $hour -le 23 ]
  do
    echo Update data for day=$day hour=$hour
    rasql --user rasadmin --passwd rasadmin --quiet --query "update MemTestData as c set c[2016, 12, $day, $hour, 00, *:*, *:*] assign marray x in [0:899, 0:899] values 4711us"
    let hour=$hour+1
  done
  let day=$day+1
done

