From 60b8d73ef4646a016f386f0e7964c8c90e613649 Mon Sep 17 00:00:00 2001 From: mortenbra Date: Sat, 29 Jul 2017 12:28:51 +0200 Subject: [PATCH 1/6] Removed beta description for utPLSQL --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c3b44c0..58ec8fc 100644 --- a/README.md +++ b/README.md @@ -264,7 +264,7 @@ This library is a collection of various utility packages for PL/SQL, as well as ##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) From 243ddbb12ee1b0e803ca2e908d288e93572b27f0 Mon Sep 17 00:00:00 2001 From: Dmitry Kurelchuk Date: Fri, 11 Aug 2017 21:56:35 +0000 Subject: [PATCH 2/6] Fixed link to AWS logo --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 58ec8fc..2bc66e4 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,10 @@ This library is a collection of various utility packages for PL/SQL, as well as ##Working with Office 2007 (OOXML) files using PL/SQL -
+ + + +
* 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/ @@ -121,7 +124,7 @@ This library is a collection of various utility packages for PL/SQL, as well as ##Integrate with Amazon web services (Simple Storage Service S3) using PL/SQL -
+
* 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 From 5e9247cd9a041c2194b59dc7fc7a0008ff08e739 Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Sun, 5 Nov 2017 12:06:50 +0530 Subject: [PATCH 3/6] fixed markdown syntax error. Just a small contribution. --- README.md | 80 +++++++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 2bc66e4..700698d 100644 --- a/README.md +++ b/README.md @@ -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,11 +30,11 @@ 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 @@ -46,14 +46,14 @@ This library is a collection of various utility packages for PL/SQL, as well as * http://www.docufy.be/ * OOXML_UTIL_PKG -##Zip and unzip files using PL/SQL +## Zip and unzip files using PL/SQL
* 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
@@ -61,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
@@ -70,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
@@ -97,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/ @@ -112,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
@@ -122,7 +122,7 @@ 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
@@ -131,19 +131,19 @@ This library is a collection of various utility packages for PL/SQL, as well as * AMAZON_AWS_AUTH_PKG * AMAZON_AWS_S3_PKG -##Integrate with PayPal web services +## Integrate with PayPal web services
* PAYPAL_UTIL_PKG -##Integrate with Twitter using PL/SQL +## Integrate with Twitter using PL/SQL
* 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/ @@ -154,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
* 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
* 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
* SQL_BUILDER_PKG * SQL_UTIL_PKG -##XML utilities +## XML utilities
@@ -201,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 @@ -241,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/ * 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/ From 48807a2ad58f562b7ca2576241f48d3c4d79b5df Mon Sep 17 00:00:00 2001 From: Morten Braten Date: Tue, 20 Feb 2018 11:51:16 +0100 Subject: [PATCH 4/6] Slack utility package --- ora/slack_util_pkg.pkb | 211 +++++++++++++++++++++++++++++++++++++++++ ora/slack_util_pkg.pks | 35 +++++++ 2 files changed, 246 insertions(+) create mode 100644 ora/slack_util_pkg.pkb create mode 100644 ora/slack_util_pkg.pks diff --git a/ora/slack_util_pkg.pkb b/ora/slack_util_pkg.pkb new file mode 100644 index 0000000..c9b045c --- /dev/null +++ b/ora/slack_util_pkg.pkb @@ -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; +/ + diff --git a/ora/slack_util_pkg.pks b/ora/slack_util_pkg.pks new file mode 100644 index 0000000..b0ecc47 --- /dev/null +++ b/ora/slack_util_pkg.pks @@ -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; +/ + From 8484dc1f9a0a69c5dfcecc95ae2b7261debd5da4 Mon Sep 17 00:00:00 2001 From: Morten Braten Date: Tue, 20 Feb 2018 11:55:21 +0100 Subject: [PATCH 5/6] Added Slack package to install scripts --- setup/install.sql | 2 ++ setup/synonyms.sql | 1 + 2 files changed, 3 insertions(+) diff --git a/setup/install.sql b/setup/install.sql index 03e66f0..3d8edf6 100755 --- a/setup/install.sql +++ b/setup/install.sql @@ -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 diff --git a/setup/synonyms.sql b/setup/synonyms.sql index 159a59f..345079a 100755 --- a/setup/synonyms.sql +++ b/setup/synonyms.sql @@ -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; From a1afda54bc5b5e3d2e50fdd3f27c0d271d4c6d3a Mon Sep 17 00:00:00 2001 From: Morten Braten Date: Wed, 21 Feb 2018 20:43:24 +0100 Subject: [PATCH 6/6] Added demo script for Slack utility package --- demos/slack_util_pkg_demo.sql | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 demos/slack_util_pkg_demo.sql diff --git a/demos/slack_util_pkg_demo.sql b/demos/slack_util_pkg_demo.sql new file mode 100644 index 0000000..2927455 --- /dev/null +++ b/demos/slack_util_pkg_demo.sql @@ -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 .'); +end; +/ + + +