emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Michael Welle <mwe012008@gmx.net>
To: emacs-orgmode@gnu.org
Subject: Re: Is it possible to pass variable to variables of src block?
Date: Wed, 13 Dec 2017 10:57:28 +0100	[thread overview]
Message-ID: <87fu8fosqf.fsf@luisa.c0t0d0s0.de> (raw)
In-Reply-To: <CANO68EMA5Abr1wBsoZ386i+b36QzXyT4d8Ssfxszr88jkGiNKg@mail.gmail.com> (Xi Shen's message of "Tue, 12 Dec 2017 06:30:01 +0000")

Hello,

Xi Shen <davidshen84@gmail.com> writes:

> Hi Michael,
>
> Yes, I think this is a way to my previous question. But what I really want
> to achieve is to loop through a list of server names and execute a script
> on them.
>
> Say I have 20 different database server. How can I do a loop with each
> server?
interestingly I did not found a good solution after a bit of thinking...
The best I could come up with is something like this (which doesn't work):


#+name: foosql
#+BEGIN_SRC sql :dbuser weather :database environment :engine postgresql
select time, temperature from weather limit 10;
#+END_SRC


#+begin_src emacs-lisp :results raw :var hosts=(list "db1" "db2" "db3")
(dolist (host hosts)
  (org-sbe foosql (concat ":dbhost " host)))
#+end_src

Error: Symbol's definition is void: host. I guess that's caused by the
way the macro is evaluated. And the result, if any, of the sql query had
to be transformed back into a nice table for some use cases.

Using other means of calling a code block, like #+call etc., aren't
suitable for usage in a loop. So maybe someone can come up with a nice
solution ;).

Regards
hmw

      parent reply	other threads:[~2017-12-13  9:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-05  5:19 Is it possible to pass variable to variables of src block? Xi Shen
2017-12-06  9:31 ` Michael Welle
2017-12-12  6:30   ` Xi Shen
2017-12-12  7:17     ` Ihor Radchenko
2017-12-13  9:57     ` Michael Welle [this message]

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=87fu8fosqf.fsf@luisa.c0t0d0s0.de \
    --to=mwe012008@gmx.net \
    --cc=emacs-orgmode@gnu.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).