From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Sebastien Vauban" Subject: [babel] Noweb expansion, not noweb evaluation... Date: Mon, 31 Oct 2011 17:22:13 +0100 Message-ID: <80mxchuo5m.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: 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-mXXj517/zsQ@public.gmane.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org Hi Eric, * Overview In order to be able to create a big code from small chunks, I need to compose with the *expanded* view of a block, instead of its *evaluated* result. I don't see how to do that while keeping the small block *executable*. * Use case A use case could explain the need in a much clearer manner. I have a SQL block that duplicates a row: #+srcname: insert-duplicate-row-with-ID #+begin_src sql :var table="order" :var column="ID" :var source_value="'73-0007'" :var target_value="'73-0008'" INSERT INTO $table ... #+end_src This block is executable, that is I can call it on the fly to make what I mean. This is good. Now, I wanna make use of that general "function" in a long stored procedure, customized to duplicate a row in a large set of tables. Something like this: #+begin_src sql :noweb yes CREATE PROCEDURE clone_row_with_ID @source_value varchar(16), @target_value varchar(16) AS <> <> ... <> GO #+end_src But this does not work, as Babel replaces the Noweb call with the results of its evaluation, not with the results of its *expansion*. Is there a way to get it working? * Workaround A very ugly workaround which I see is that: - the reference block prints out SQL code: for example, an AWK code printing SQL statement. - the general block calls Noweb, and receives the output of AWK's execution, hence expanded SQL code. But, then, the reference block is not executable anymore. Not really a workaround, then... Best regards, Seb -- Sebastien Vauban