emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [babel] (Almost) Add SQL*Plus engine
@ 2011-11-22 14:31 Sebastien Vauban
  0 siblings, 0 replies; only message in thread
From: Sebastien Vauban @ 2011-11-22 14:31 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-11-22 14:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-22 14:31 [babel] (Almost) Add SQL*Plus engine Sebastien Vauban

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).