emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sebastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>
To: emacs-orgmode-mXXj517/zsQ@public.gmane.org
Subject: [babel] (Almost) Add SQL*Plus engine
Date: Tue, 22 Nov 2011 15:31:30 +0100	[thread overview]
Message-ID: <80r510w7nh.fsf@somewhere.org> (raw)

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

                 reply	other threads:[~2011-11-22 14:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=80r510w7nh.fsf@somewhere.org \
    --to=wxhgmqzgwmuf-genee64ty+gs+fvcfc7uqw@public.gmane.org \
    --cc=emacs-orgmode-mXXj517/zsQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).