Skip to content

Instantly share code, notes, and snippets.

@ajin
Created September 13, 2016 18:27
Show Gist options
  • Save ajin/5d6c20e387bba601c5c8fdfb306788ce to your computer and use it in GitHub Desktop.
Save ajin/5d6c20e387bba601c5c8fdfb306788ce to your computer and use it in GitHub Desktop.
declare
l_access_granted number := 0;
l_status varchar2(10);
l_message varchar2(254);
l_mac varchar2(254);
l_key varchar2(254);
begin
l_mac := :muid;
l_key := :kuid;
insert into rfidx_access_history (mac, key) values (l_mac, l_key);
select count(1) into l_access_granted from rfidx_keycard
where key = l_key;
if l_access_granted > 0 then
l_status := 'OK';
l_message := 'Access granted. Welcome';
else
l_status := 'NOK';
l_message := 'Denied!';
end if;
-- Write header for the JSON stream.
apex_plugin_util.print_json_http_header;
sys.htp.p('{');
sys.htp.p('"status": "' || l_status || '",');
sys.htp.p('"message": "' || l_message || '"');
sys.htp.p('}');
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment