* [babel] Noweb expansion, not noweb evaluation...
@ 2011-10-31 16:22 Sebastien Vauban
0 siblings, 0 replies; only message in thread
From: Sebastien Vauban @ 2011-10-31 16:22 UTC (permalink / raw)
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:
#+begin_src sql :var table="order" :var column="ID" :var source_value="'73-0007'" :var target_value="'73-0008'"
INSERT INTO $table
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
<<insert-duplicate-row-with-ID("table1", "column", "@source_value", "@target_value")>>
<<insert-duplicate-row-with-ID("table2", "column", "@source_value", "@target_value")>>
<<insert-duplicate-row-with-ID("tableN", "column", "@source_value", "@target_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?
A very ugly workaround which I see is that:
- the reference block prints out SQL code: for example, an AWK code printing
- 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-10-31 16:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-31 16:22 [babel] Noweb expansion, not noweb evaluation Sebastien Vauban
Code repositories for project(s) associated with this public inbox
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).