From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Sebastien Vauban" Subject: [babel] (Almost) Add SQL*Plus engine Date: Tue, 22 Nov 2011 15:31:30 +0100 Message-ID: <80r510w7nh.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org Hi Eric, I almost added the engine `sqlplus' (from Oracle Instant client) to `ob-sql': #+begin_src emacs-lisp ('sqlplus (format "sqlplus -S %s @%s > %s" (or cmdline "") (org-babel-process-file-name in-file) (org-babel-process-file-name out-file))) #+end_src where: - `S' is to remove the Oracle banner - `user/pass@server' is the logon info (given as `cmdline') - `@file' is the way to pass an SQL script to be run (file name is preceded by an `@' sign). BUT the code block to be executed is saved by Babel in Windows' TEMP directory, for example under a file whose full path is: c:\WINDOWS\TEMP\babel-511607b\sql-in-5116n4J There is no file extension there. This becomes important... as SQL*Plus seems to always add the `sql' extension to the script file name, when they don't have one: #+begin_src sh $ sqlplus -S user/pass@server @c\:/WINDOWS/TEMP/babel-511607b/sql-in-5116n4J ^^^^^^^^^^^^^^ SP2-0310: unable to open file "c:/WINDOWS/TEMP/babel-511607b/sql-in-5116n4J.sql" #+end_src ^^^^^^^^^^^^^^^^^^ If I go and add an `sql' extension to that temporary file, in the file system, the script is well read and executed: #+begin_src sql $ sqlplus -S user/pass@server @c\:/WINDOWS/TEMP/babel-511607b/sql-in-5116n4J.sql ^^^^^^^^^^^^^^^^^^ SELECT * FROM employees * ERROR at line 1: ORA-00942: table or view does not exist #+end_src Here, the command is executed, but fails because it's just a sample command, and there is no such table. So, in order to get the `sqlplus' engine working, it seems necessary to add the language extension to the file name hosting temporarily the code snippet. In a way, it's even cleaner: would we open it under Emacs, we directly get the proper highlighting, etc. But there was maybe a reason it hadn't been done that way? What do you think? Best regards, Seb -- Sebastien Vauban