Hello,

Xi Shen <davidshe...@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

Reply via email to