* [PATCH] ob-sql.el: Add support for Oracle via sqlplus
@ 2015-12-18 9:44 Peter Feigl
2015-12-20 15:58 ` Nicolas Goaziou
0 siblings, 1 reply; 2+ messages in thread
From: Peter Feigl @ 2015-12-18 9:44 UTC (permalink / raw)
To: emacs-orgmode
* lisp/ob-sql.el: Add a database type 'oracle that uses sqlplus to
support running SQL blocks against an Oracle database.
Use with properties like this (all mandatory):
:engine oracle :dbhost <host.com> :dbport <1521> :dbuser <username>
:database <database> :dbpassword <secret>
TINYCHANGE
---
lisp/ob-sql.el | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
index 955adc0..a909298 100644
--- a/lisp/ob-sql.el
+++ b/lisp/ob-sql.el
@@ -99,6 +99,10 @@ Pass nil to omit that arg."
(when user (concat "-U" user))
(when database (concat "-d" database))))))
+(defun org-babel-sql-dbstring-oracle (host port user password database)
+ "Make Oracle command line args for database connection."
+ (format "%s/%s@%s:%s/%s" user password host port database))
+
(defun org-babel-execute:sql (body params)
"Execute a block of Sql code with Babel.
This function is called by `org-babel-execute-src-block'."
@@ -143,11 +147,29 @@ This function is called by `org-babel-execute-src-block'."
(org-babel-process-file-name in-file)
(org-babel-process-file-name out-file)
(or cmdline "")))
+ ('oracle (format
+ "sqlplus -s %s < %s > %s"
+ (org-babel-sql-dbstring-oracle dbhost dbport dbuser dbpassword database)
+ (org-babel-process-file-name in-file)
+ (org-babel-process-file-name out-file)))
(t (error "No support for the %s SQL engine" engine)))))
(with-temp-file in-file
(insert
(case (intern engine)
('dbi "/format partbox\n")
+ ('oracle "SET PAGESIZE 50000
+SET NEWPAGE 0
+SET TAB OFF
+SET SPACE 0
+SET LINESIZE 9999
+SET ECHO OFF
+SET FEEDBACK OFF
+SET VERIFY OFF
+SET HEADING ON
+SET MARKUP HTML OFF SPOOL OFF
+SET COLSEP '|'
+
+")
(t ""))
(org-babel-expand-body:sql body params)))
(message command)
--
2.6.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ob-sql.el: Add support for Oracle via sqlplus
2015-12-18 9:44 [PATCH] ob-sql.el: Add support for Oracle via sqlplus Peter Feigl
@ 2015-12-20 15:58 ` Nicolas Goaziou
0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2015-12-20 15:58 UTC (permalink / raw)
To: Peter Feigl; +Cc: emacs-orgmode
Hello,
Peter Feigl <peter.feigl@nexoid.at> writes:
> * lisp/ob-sql.el: Add a database type 'oracle that uses sqlplus to
> support running SQL blocks against an Oracle database.
>
> Use with properties like this (all mandatory):
> :engine oracle :dbhost <host.com> :dbport <1521> :dbuser <username>
> :database <database> :dbpassword <secret>
>
> TINYCHANGE
Applied. Thank you.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-20 15:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-18 9:44 [PATCH] ob-sql.el: Add support for Oracle via sqlplus Peter Feigl
2015-12-20 15:58 ` Nicolas Goaziou
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).