MyFirstUDRKit/sql/MyFirstUDRKitPackage.sql

56 lines
931 B
MySQL
Raw Permalink Normal View History

2023-01-23 15:31:22 +01:00
/*
2023-01-26 16:41:07 +01:00
* This demonstrates how to declare the UDRs as part of a package
*
* ########### INCOMPLETE ###################
2023-01-23 15:31:22 +01:00
*/
2023-01-23 13:42:02 +01:00
set term ^;
2023-01-25 15:58:51 +01:00
create or alter package MyFirstUDRKit
2023-01-26 16:41:07 +01:00
-- -- optional - declare sql security as DEFINER to give access rights of owner to all users
2023-01-23 13:42:02 +01:00
-- sql security definer
as
begin
function div (
anumerator bigint, adenominator bigint
2023-01-23 13:42:02 +01:00
)
returns bigint;
2023-01-23 13:42:02 +01:00
function flagged (
flags integer, flag integer
)
returns integer;
end ^
2023-01-25 15:58:51 +01:00
recreate package body MyFirstUDRKit
2023-01-23 13:42:02 +01:00
as
begin
function div (
anumerator bigint, adenominator bigint
)
returns bigint
2023-01-25 15:58:51 +01:00
external name 'MyFirstUDRKit!MFK_div!Divide anumerator by adenominator' engine udr;
2023-01-23 13:42:02 +01:00
function flagged (
flags integer, flag integer
2023-01-25 09:53:53 +01:00
)
returns integer
2023-01-26 16:41:07 +01:00
external name 'MyFirstUDRKit!MFK_flagged!Check if flag is set in flags. flag is zero-based.' engine udr;
2023-01-25 09:53:53 +01:00
2023-01-23 13:42:02 +01:00
end ^
set term ;^
2023-01-23 15:43:39 +01:00
2023-01-25 15:58:51 +01:00
grant execute on package MyFirstUDRKit to public;