From fd4ae337ac3a38bc9c9a422628482d6f46599bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20T=C3=A9choueyres?= Date: Thu, 15 Mar 2018 19:15:14 +0100 Subject: [PATCH] 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 : /@:/ or /@ --- lisp/ob-sql.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index f44bf5674..d030cf528 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -112,10 +112,13 @@ 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 /@:/ or +/@ using it's alias." + (cond ((and user password database (not (and host port))) (format "%s/%s@%s" user password database)) + ((and user password database host port) (format "%s/%s@%s:%s/%s" user password host port 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. -- 2.14.3