This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

SQL challenge yet again
#5
OK, so I was able to do it with the tips I got. Thanks for help!

If anyone alse need this function, just copy this code and modify to your liking;
Code:
start = '26/0/0'
stop = '26/0/255'

------------------------------------------------------------------------------------
--------------------NO CHANGES BELOW THE LINE---------------------------------------

startHG = tonumber(string.split(start, '/')[1])
startMG = tonumber(string.split(start, '/')[2])
startUG = tonumber(string.split(start, '/')[3])

startID = (startHG * 2048) + (startMG * 256) + startUG


stopHG = tonumber(string.split(stop, '/')[1])
stopMG = tonumber(string.split(stop, '/')[2])
stopUG = tonumber(string.split(stop, '/')[3])

stopID = (stopHG * 2048) + (stopMG * 256) + stopUG

if stopID < startID then
  log('Start has higher value than stop. Delete is not possible')
else
  log('Addresses within range are deleted')
  adresser = db:getall('SELECT address, name FROM objects WHERE ID BETWEEN "' .. startID .. '" AND  "' .. stopID .. '"')
  for _, addr in ipairs(adresser) do
    log(addr.name)
    grp.delete(addr.name)
  end
end
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply


Messages In This Thread
SQL challenge yet again - by Trond Hoyem - 16.09.2019, 13:31
RE: SQL challenge yet again - by Daniel - 16.09.2019, 14:25
RE: SQL challenge yet again - by admin - 16.09.2019, 18:50
RE: SQL challenge yet again - by Trond Hoyem - 17.09.2019, 19:43
RE: SQL challenge yet again - by Trond Hoyem - 20.09.2019, 12:00
RE: SQL challenge yet again - by Daniel - 20.09.2019, 12:02
RE: SQL challenge yet again - by Trond Hoyem - 20.09.2019, 12:09
RE: SQL challenge yet again - by Trond Hoyem - 25.09.2019, 06:33

Forum Jump: