From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Welle Subject: Re: Is it possible to pass variable to variables of src block? Date: Wed, 13 Dec 2017 10:57:28 +0100 Message-ID: <87fu8fosqf.fsf@luisa.c0t0d0s0.de> References: <877eu0gq3p.fsf@luisa.c0t0d0s0.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eP3nE-0001fy-FW for emacs-orgmode@gnu.org; Wed, 13 Dec 2017 04:57:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eP3nB-0004cU-Dk for emacs-orgmode@gnu.org; Wed, 13 Dec 2017 04:57:36 -0500 Received: from mout.gmx.net ([212.227.17.22]:51326) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eP3nB-0004bT-3P for emacs-orgmode@gnu.org; Wed, 13 Dec 2017 04:57:33 -0500 Received: from stella.c0t0d0s0.de ([194.95.66.1]) by mail.gmx.com (mrgmx101 [212.227.17.168]) with ESMTPSA (Nemesis) id 0Lat5o-1erTf8317A-00kNrR for ; Wed, 13 Dec 2017 10:57:30 +0100 Received: from Stella (stella.c0t0d0s0.de [192.168.42.1]) by stella.c0t0d0s0.de (Postfix) with ESMTP id 47559C409C for ; Wed, 13 Dec 2017 10:57:28 +0100 (CET) In-Reply-To: (Xi Shen's message of "Tue, 12 Dec 2017 06:30:01 +0000") 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@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Hello, Xi Shen 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