Merge remote-tracking branch 'upstream/master'

This commit is contained in:
eaolson 2018-06-17 11:28:30 -05:00
commit ae93c96e28
6 changed files with 311 additions and 43 deletions

View File

@ -6,7 +6,7 @@ Oracle PL/SQL Utility Library
This library is a collection of various utility packages for PL/SQL, as well as links to useful libraries hosted and maintained elsewhere.
##Generate PDF files using PL/SQL
## Generate PDF files using PL/SQL
* https://technology.amis.nl/2012/04/11/generating-a-pdf-document-with-some-plsql-as_pdf_mini-as_pdf3/
@ -19,7 +19,7 @@ This library is a collection of various utility packages for PL/SQL, as well as
* PDFGEN_PKG
##Generate Excel files using PL/SQL
## Generate Excel files using PL/SQL
* https://technology.amis.nl/2011/02/19/create-an-excel-file-with-plsql/
* http://www.jasonsdevelopercorner.com/?page_id=8
@ -30,27 +30,30 @@ This library is a collection of various utility packages for PL/SQL, as well as
* XLSX_BUILDER_PKG
* SYLK_UTIL_PKG
##Generate RTF files using PL/SQL
## Generate RTF files using PL/SQL
* http://monkeyonoracle.blogspot.com/2009/07/dynamic-rtf-documents-revisited.html
##Working with Office 2007 (OOXML) files using PL/SQL
## Working with Office 2007 (OOXML) files using PL/SQL
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/1/1b/X-office-document.svg/48px-X-office-document.svg.png" align="right" /><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/0/07/X-office-presentation.svg/48px-X-office-presentation.svg.png" align="right" /><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/X-office-spreadsheet.svg/48px-X-office-spreadsheet.svg.png" align="right" /><br>
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/1/1b/X-office-document.svg/48px-X-office-document.svg.png" align="right" />
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/0/07/X-office-presentation.svg/48px-X-office-presentation.svg.png" align="right" />
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/X-office-spreadsheet.svg/48px-X-office-spreadsheet.svg.png" align="right" />
<br>
* http://ora-00001.blogspot.com/2011/02/working-with-office-2007-ooxml-files.html
* https://technology.amis.nl/2010/06/09/parsing-a-microsoft-word-docx-and-unzip-zipfiles-with-plsql/
* http://www.docufy.be/
* OOXML_UTIL_PKG
##Zip and unzip files using PL/SQL
## Zip and unzip files using PL/SQL
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/9/9c/The_Unarchiver_zip.png/64px-The_Unarchiver_zip.png" align="right" /><br>
* https://technology.amis.nl/2010/03/13/utl_compress-gzip-and-zlib/
* ZIP_UTIL_PKG
##Generate and parse CSV files using PL/SQL
## Generate and parse CSV files using PL/SQL
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/3/38/CsvDelimited001.svg/113px-CsvDelimited001.svg.png" align="right" /><br>
@ -58,7 +61,7 @@ This library is a collection of various utility packages for PL/SQL, as well as
* CSV_UTIL_PKG
##Generate and parse RSS feeds using PL/SQL
## Generate and parse RSS feeds using PL/SQL
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/4/43/Feed-icon.svg/75px-Feed-icon.svg.png" align="right" /><br>
@ -67,25 +70,25 @@ This library is a collection of various utility packages for PL/SQL, as well as
* RSS_UTIL_PKG
##Generate JSON using PL/SQL
## Generate JSON using PL/SQL
* http://ora-00001.blogspot.com/2010/02/ref-cursor-to-json.html
* JSON_UTIL_PKG
##Parse JSON using PL/SQL
## Parse JSON using PL/SQL
* https://github.com/pljson/pljson
* http://reseau.erasme.org/pl-sql-library-for-JSON?lang=en
##Transfer files (FTP) using PL/SQL
## Transfer files (FTP) using PL/SQL
* http://www.oracle-base.com/articles/misc/FTPFromPLSQL.php
* FTP_UTIL_PKG
##Send email (SMTP) using PL/SQL
## Send email (SMTP) using PL/SQL
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b1/Arobaze.svg/75px-Arobaze.svg.png" align="right" /><br>
@ -94,12 +97,12 @@ This library is a collection of various utility packages for PL/SQL, as well as
* MAIL_UTIL_PKG
##Receive email (POP3) using PL/SQL
## Receive email (POP3) using PL/SQL
* POP3_UTIL_PKG
##Receive email (POP3 and IMAP) using PL/SQL (and Java)
## Receive email (POP3 and IMAP) using PL/SQL (and Java)
* http://plsqlmailclient.sourceforge.net/
@ -109,7 +112,7 @@ This library is a collection of various utility packages for PL/SQL, as well as
* MS_EWS_UTIL_PKG
##Integrate with Google services (Google Maps, Google Calendar, Google Translate) using PL/SQL
## Integrate with Google services (Google Maps, Google Calendar, Google Translate) using PL/SQL
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/3/30/Googlelogo.png/200px-Googlelogo.png" align="right" /><br>
@ -119,28 +122,28 @@ This library is a collection of various utility packages for PL/SQL, as well as
* GOOGLE_MAPS_PKG
* GOOGLE_TRANSLATE_PKG
##Integrate with Amazon web services (Simple Storage Service S3) using PL/SQL
## Integrate with Amazon web services (Simple Storage Service S3) using PL/SQL
<img src="http://upload.wikimedia.org/wikipedia/en/thumb/1/1d/AmazonWebservices_Logo.svg/250px-AmazonWebservices_Logo.svg.png" align="right" /><br>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/1d/AmazonWebservices_Logo.svg/200px-AmazonWebservices_Logo.svg.png" align="right" /><br>
* http://ora-00001.blogspot.com/2011/03/amazon-s3-api-for-plsql.html
* http://jastraub.blogspot.com/2011/01/building-amazon-s3-client-with.html
* AMAZON_AWS_AUTH_PKG
* AMAZON_AWS_S3_PKG
##Integrate with PayPal web services
## Integrate with PayPal web services
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/3/39/PayPal_logo.svg/200px-PayPal_logo.svg.png" align="right" /><br>
* PAYPAL_UTIL_PKG
##Integrate with Twitter using PL/SQL
## Integrate with Twitter using PL/SQL
<img src="http://upload.wikimedia.org/wikipedia/en/9/9f/Twitter_bird_logo_2012.svg" width="100" align="right" /><br>
* http://oratweet.com/
##Call SOAP and REST web services using PL/SQL
## Call SOAP and REST web services using PL/SQL
* http://jastraub.blogspot.com/2008/06/flexible-web-service-api.html
* https://flex-ws-api.samplecode.oracle.com/
@ -151,44 +154,44 @@ This library is a collection of various utility packages for PL/SQL, as well as
* T_SOAP_ENVELOPE
##Publish SOAP web service using PL/SQL
## Publish SOAP web service using PL/SQL
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/5/59/SOAP.svg/182px-SOAP.svg.png" align="right" /><br>
* http://ora-00001.blogspot.com/2011/01/soap-server-in-plsql.html
* SOAP_SERVER_PKG
##Publish REST web services using PL/SQL
## Publish REST web services using PL/SQL
* http://ora-00001.blogspot.com/2009/07/creating-rest-web-service-with-plsql.html
* http://www.oracle-base.com/articles/misc/XMLOverHTTP.php
##Regular expressions using PL/SQL
## Regular expressions using PL/SQL
<img src="http://upload.wikimedia.org/math/2/a/8/2a8ea57cab60c6ac9279fbf68e37ba0d.png" align="right" /><br>
* REGEXP_UTIL_PKG
##String, date and math utilities
## String, date and math utilities
* DATE_UTIL_PKG
* MATH_UTIL_PKG
* STRING_UTIL_PKG
##Encoding and data type utilities
## Encoding and data type utilities
* ENCODE_UTIL_PKG
* RAW_UTIL_PKG
##SQL utilities
## SQL utilities
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/a/aa/SQL_ANATOMY_wiki.svg/275px-SQL_ANATOMY_wiki.svg.png" align="right" /><br>
* SQL_BUILDER_PKG
* SQL_UTIL_PKG
##XML utilities
## XML utilities
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/6/68/XML.svg/125px-XML.svg.png" align="right" /><br>
@ -198,38 +201,38 @@ This library is a collection of various utility packages for PL/SQL, as well as
* XML_STYLESHEET_PKG
* XML_UTIL_PKG
##File utilities
## File utilities
* FILE_UTIL_PKG
##HTTP utilities
## HTTP utilities
* HTTP_UTIL_PKG
##Encryption and security utilities and protocols
## Encryption and security utilities and protocols
* http://ora-00001.blogspot.com/2011/08/ntlm-for-plsql.html
* CRYPTO_UTIL_PKG
* NTLM_UTIL_PKG
* NTLM_HTTP_PKG
##Logging and debugging utilities
## Logging and debugging utilities
* https://github.com/tmuth/Logger---A-PL-SQL-Logging-Utility
* http://sourceforge.net/projects/log4plsql/
* http://sourceforge.net/projects/ilo/
* DEBUG_PKG
##Generating test data and random bits using PL/SQL
## Generating test data and random bits using PL/SQL
* http://ora-00001.blogspot.com/2011/02/generating-test-data-using-plsql.html
* RANDOM_UTIL_PKG
##PL/SQL Web Toolkit (OWA) utilities
## PL/SQL Web Toolkit (OWA) utilities
* OWA_UTIL_PKG
##Web Gateways for PL/SQL
## Web Gateways for PL/SQL
* http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_epg.htm
* http://download.oracle.com/docs/cd/B14099_19/web.1012/b14010/toc.htm
@ -238,40 +241,40 @@ This library is a collection of various utility packages for PL/SQL, as well as
* http://sourceforge.net/projects/dbprism/
* http://oss.oracle.com/projects/mod_owa/dist/documentation/modowa.htm
##jQGrid Integration Kit for PL/SQL and Apex
## jQGrid Integration Kit for PL/SQL and Apex
* http://ora-00001.blogspot.com/2010/03/jqgrid-integration-kit-for-plsql-and.html
* http://code.google.com/p/jqgrid-for-plsql/
##Application Express APIs
## Application Express APIs
* http://download.oracle.com/docs/cd/E17556_01/doc/apirefs.40/e15519/toc.htm
* APEX_UTIL_PKG
##Miscellaneous utilities and demos
## Miscellaneous utilities and demos
* http://www.oracle.com/webfolder/technetwork/tutorials/plsql/sfdemo.zip
* http://www.toadworld.com/platforms/oracle/w/wiki/8243.plsql-obsession
##PL/SQL Frameworks
## PL/SQL Frameworks
* http://sourceforge.net/projects/plsqlframestart/
* http://www.toadworld.com/Freeware/PLVisionFreeware/tabid/687/Default.aspx
##PL/SQL Wrappers for Java
## PL/SQL Wrappers for Java
* http://sourceforge.net/projects/oracle-jutils/
##Unit Testing Frameworks for PL/SQL
## Unit Testing Frameworks for PL/SQL
* https://utplsql.github.io/ (version 3 beta)
* https://utplsql.github.io/
* http://code.google.com/p/pluto-test-framework/
##Documentation Generators (JavaDoc-style)
## Documentation Generators (JavaDoc-style)
* http://sourceforge.net/projects/plsqlutils/
* http://www.thatjeffsmith.com/archive/2012/03/javadoc-for-the-database-a-la-dbdoc-via-sql-developer/
##Scripting, deployment and installation utilities
## Scripting, deployment and installation utilities
* http://code.google.com/p/oracle-ddl2svn/

View File

@ -0,0 +1,16 @@
-- send message to Slack using webhook
-- see https://api.slack.com/incoming-webhooks
begin
-- create your own incoming webhook in Slack, then paste the path to the webhook here
slack_util_pkg.set_webhook_path ('/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX');
-- send a basic message
slack_util_pkg.send_message ('Hello Slack World!');
-- send a formatted message
slack_util_pkg.send_message ('Hello *Slack* World! This is a _message from PL/SQL_ sent using the <https://github.com/mortenbra|Alexandria PL/SQL Utility Library>.');
end;
/

211
ora/slack_util_pkg.pkb Normal file
View File

@ -0,0 +1,211 @@
create or replace package body slack_util_pkg
as
/*
Purpose: Package handles Slack API
Remarks: see https://api.slack.com/
Who Date Description
------ ---------- --------------------------------
MBR 17.02.2018 Created
*/
g_api_base_url string_util_pkg.t_max_db_varchar2 := 'https://slack.com/api';
g_webhook_host string_util_pkg.t_max_db_varchar2 := 'https://hooks.slack.com';
g_webhook_path string_util_pkg.t_max_db_varchar2;
g_wallet_path string_util_pkg.t_max_db_varchar2;
g_wallet_password string_util_pkg.t_max_db_varchar2;
procedure assert (p_condition in boolean,
p_error_message in varchar2)
as
begin
/*
Purpose: assert condition is true, otherwise raise an error
Remarks:
Who Date Description
------ ---------- --------------------------------
MBR 20.02.2018 Created
*/
if (p_condition is null) or (not p_condition) then
raise_application_error (-20000, p_error_message);
end if;
end assert;
function make_request (p_url in varchar2,
p_body in clob := null,
p_http_method in varchar2 := 'POST') return clob
as
l_http_status_code pls_integer;
l_returnvalue clob;
begin
/*
Purpose: make HTTP request
Remarks:
Who Date Description
------ ---------- --------------------------------
MBR 17.02.2018 Created
*/
apex_web_service.g_request_headers.delete;
apex_web_service.g_request_headers(1).name := 'Content-Type';
apex_web_service.g_request_headers(1).value := 'application/json';
l_returnvalue := apex_web_service.make_rest_request(
p_url => p_url,
p_http_method => p_http_method,
p_body => p_body,
p_wallet_path => g_wallet_path,
p_wallet_pwd => g_wallet_password
);
l_http_status_code := apex_web_service.g_status_code;
-- for possible error codes, see https://api.slack.com/changelog/2016-05-17-changes-to-errors-for-incoming-webhooks
assert (l_http_status_code = 200, 'Request failed with HTTP error code ' || l_http_status_code || '. First 1K of response body: ' || substr(l_returnvalue, 1, 1000) );
return l_returnvalue;
end make_request;
procedure set_api_base_url (p_url in varchar2)
as
begin
/*
Purpose: set API base URL
Remarks: useful if you need to use a proxy for HTTPS requests from the database
see http://blog.rhjmartens.nl/2015/07/making-https-webservice-requests-from.html
see http://ora-00001.blogspot.com/2016/04/how-to-set-up-iis-as-ssl-proxy-for-utl-http-in-oracle-xe.html
Who Date Description
------ ---------- --------------------------------
MBR 17.02.2018 Created
*/
g_api_base_url := p_url;
end set_api_base_url;
procedure set_wallet (p_wallet_path in varchar2,
p_wallet_password in varchar2)
as
begin
/*
Purpose: set SSL wallet properties
Remarks:
Who Date Description
------ ---------- --------------------------------
MBR 17.02.2018 Created
*/
g_wallet_path := p_wallet_path;
g_wallet_password := p_wallet_password;
end set_wallet;
procedure set_webhook_host (p_host in varchar2)
as
begin
/*
Purpose: set webhook host
Remarks:
Who Date Description
------ ---------- --------------------------------
MBR 17.02.2018 Created
*/
g_webhook_host := p_host;
end set_webhook_host;
procedure set_webhook_path (p_path in varchar2)
as
begin
/*
Purpose: set webhook path
Remarks:
Who Date Description
------ ---------- --------------------------------
MBR 17.02.2018 Created
*/
g_webhook_path := p_path;
end set_webhook_path;
procedure send_message (p_text in varchar2)
as
l_response clob;
begin
/*
Purpose: send message
Remarks:
Who Date Description
------ ---------- --------------------------------
MBR 17.02.2018 Created
*/
assert (g_webhook_host is not null, 'Webhook host not defined!');
assert (g_webhook_path is not null, 'Webhook path not defined!');
l_response := make_request (
p_url => g_webhook_host || g_webhook_path,
p_body => '{ "text": ' || apex_json.stringify (p_text) || ' }'
);
end send_message;
end slack_util_pkg;
/

35
ora/slack_util_pkg.pks Normal file
View File

@ -0,0 +1,35 @@
create or replace package slack_util_pkg
as
/*
Purpose: Package handles Slack API
Remarks: see https://api.slack.com/
Who Date Description
------ ---------- --------------------------------
MBR 17.02.2018 Created
*/
-- set API base URL
procedure set_api_base_url (p_url in varchar2);
-- set SSL wallet properties
procedure set_wallet (p_wallet_path in varchar2,
p_wallet_password in varchar2);
-- set webhook host
procedure set_webhook_host (p_host in varchar2);
-- set webhook path
procedure set_webhook_path (p_path in varchar2);
-- send message
procedure send_message (p_text in varchar2);
end slack_util_pkg;
/

View File

@ -40,6 +40,7 @@ prompt Creating package specifications
@../ora/raw_util_pkg.pks
@../ora/regexp_util_pkg.pks
@../ora/rss_util_pkg.pks
@../ora/slack_util_pkg.pks
@../ora/sms_util_pkg.pks
@../ora/soap_server_pkg.pks
@../ora/sql_builder_pkg.pks
@ -92,6 +93,7 @@ prompt Creating package bodies
@../ora/raw_util_pkg.pkb
@../ora/regexp_util_pkg.pkb
@../ora/rss_util_pkg.pkb
@../ora/slack_util_pkg.pkb
@../ora/sms_util_pkg.pkb
@../ora/soap_server_pkg.pkb
@../ora/sql_builder_pkg.pkb

View File

@ -35,6 +35,7 @@ create synonym ax_random for random_util_pkg;
create synonym ax_raw for raw_util_pkg;
create synonym ax_regexp for regexp_util_pkg;
create synonym ax_rss for rss_util_pkg;
create synonym ax_slack for slack_util_pkg;
create synonym ax_sms for sms_util_pkg;
create synonym ax_sql_builder for sql_builder_pkg;
create synonym ax_sql for sql_util_pkg;