emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sebastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>
To: emacs-orgmode-mXXj517/zsQ@public.gmane.org
Subject: [babel] Noweb expansion, not noweb evaluation...
Date: Mon, 31 Oct 2011 17:22:13 +0100	[thread overview]
Message-ID: <80mxchuo5m.fsf@somewhere.org> (raw)

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

                 reply	other threads:[~2011-10-31 16:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=80mxchuo5m.fsf@somewhere.org \
    --to=wxhgmqzgwmuf-genee64ty+gs+fvcfc7uqw@public.gmane.org \
    --cc=emacs-orgmode-mXXj517/zsQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).