summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Téchoueyres <pierre.techoueyres@free.fr>2018-03-15 19:15:14 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-03-16 23:01:58 +0100
commitbd0b691716a6ba38d038d6194bb5fc8a30f20f4b (patch)
tree1321d6e68d630d2272b1388fa79e34fa6bf3361e
parent6cf5fc0fc162534832e5f36ee2c532147e3be6de (diff)
downloadorg-mode-bd0b691716a6ba38d038d6194bb5fc8a30f20f4b.tar.gz
ob-sql.el: Improve Oracle connection and usage for ob-sql.
* lisp/ob-sql.el (org-babel-sql-dbstring-oracle): Permit to omit host and port to allow use of alias defined in Oracle's TNSNAMES files. This now allow two way calling it : <user>/<password>@<host>:<port>/<database ID> or <user>/<password>@<database alias>
-rw-r--r--lisp/ob-sql.el21
1 files changed, 17 insertions, 4 deletions
diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
index f44bf56..8f0cc8b 100644
--- a/lisp/ob-sql.el
+++ b/lisp/ob-sql.el
@@ -112,10 +112,23 @@ Pass nil to omit that arg."
(defun org-babel-sql-dbstring-oracle (host port user password database)
"Make Oracle command line arguments for database connection.
-If PORT and DATABASE are nil then don't pass them. This allows
-you to use names defined in your \"TNSNAMES\" file."
- (concat (format "%s/%s@%s" user password host)
- (and port database (format ":%s/%s" port database))))
+
+If HOST and PORT are nil then don't pass them. This allows you
+to use names defined in your \"TNSNAMES\" file. So you can
+connect with
+
+ <user>/<password>@<host>:<port>/<database>
+
+or
+
+ <user>/<password>@<database>
+
+using its alias."
+ (cond ((and user password database host port)
+ (format "%s/%s@%s:%s/%s" user password host port database))
+ ((and user password database)
+ (format "%s/%s@%s" user password database))
+ (t (user-error "Missing information to connect to database"))))
(defun org-babel-sql-dbstring-mssql (host user password database)
"Make sqlcmd command line args for database connection.