#!/bin/bash

Q=$1

scale=$(./qinfo $Q | grep numerator | cut -d \( -f 2 | sed s/\)/' '/g) 
sell_value="sell_value = IF(sell_value is NULL, sell_value, sell_value /${scale})"
value="value = value/${scale}"
echo "UPDATE stocks SET scaled = True," $value "," $sell_value  "WHERE NOT scaled AND id =" $Q ";"

