[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [babel] Noweb expansion, not noweb evaluation...

From: Sebastien Vauban
Subject: [O] [babel] Noweb expansion, not noweb evaluation...
Date: Mon, 31 Oct 2011 17:22:13 +0100
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (windows-nt)

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'"

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)
    <<insert-duplicate-row-with-ID("table1", "column", "@source_value", 
    <<insert-duplicate-row-with-ID("table2", "column", "@source_value", 
    <<insert-duplicate-row-with-ID("tableN", "column", "@source_value", 

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,

Sebastien Vauban

reply via email to

[Prev in Thread] Current Thread [Next in Thread]