Skip to content

Instantly share code, notes, and snippets.

@erichowey
Created February 21, 2024 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erichowey/63fca1ed59bfb45c9baea49a4d47a22c to your computer and use it in GitHub Desktop.
Save erichowey/63fca1ed59bfb45c9baea49a4d47a22c to your computer and use it in GitHub Desktop.
Using func_odbc with lua example
extensions = {
["from-external"] = {
["_X."] = function(c, e)
-- USE THE HASH FUNCTION
local destinationMetadata = {}
destinationMetadata.data = {}
app.verbose("USE THE HASH FUNCTION")
local result = channel.ODBC_GET_DESTINATION_METADATA_WHERE_ID("774733"):get()
channel.HASH("hashedResult"):set(result)
destinationMetadata.data.id = channel.HASH("hashedResult", "id"):get()
destinationMetadata.data.destination_type = channel.HASH("hashedResult", "destination_type"):get()
app.verbose(destinationMetadata.data.id)
app.verbose(destinationMetadata.data.destination_type)
-- GET MULTIPLE ROWS WITH HASH
local hours = {}
hours.data = {}
app.verbose("USE THE HASH FUNCTION MULTIGET")
local resultId = channel.ODBC_SQL_MULTI():get()
for i=1, channel.ODBCROWS:get() do
channel.HASH("hashedResult"):set(channel.ODBC_FETCH(resultId):get())
local map = {
id = channel.HASH("hashedResult", "id"):get(),
day_start = channel.HASH("hashedResult", "day_start"):get()
}
table.insert(hours.data, map)
end
channel.ODBC_Finish(resultId)
for i, hour in ipairs(hours.data) do
app.verbose(hour.id)
app.verbose(hour.day_start)
end
app.playback("veldt")
end
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment