|
From: | Gary Oberbrunner |
Subject: | Re: [O] Org-mode as a metalanguage: calling SQL "functions" |
Date: | Mon, 1 Apr 2013 22:54:14 -0400 |
Eric Abrahamsen <address@hidden> writes:Yes, your example should work. From the "Evaluating code blocks"
> Gary Oberbrunner <address@hidden> writes:
>
>> It seems like you can define "procedures" in org-mode and call them
>> from elsewhere, with args.
>> But I'm not sure how well-defined that process is; the documentation
>> is not completely perfect yet I think. Here's one thing I'm trying
>> that seems not to work.
>>
>> I define a "procedure" as a named ref called recorddate with two args,
>> ver and order. The idea is I could later call that with different
>> values of those args.
>>
>> #+NAME: recorddate(order="desc")
>> #+BEGIN_SRC sql :exports none :colnames no :results scalar
>> select Event.CreatedAt from Event join MachineInfo as MI on
>> Event.MachineInfoId=MI.Id
>> where Event.CreatedAt is not NULL order by CreatedAt $order limit 1;
>> #+END_SRC sql
>>
>> (BTW, I really like how $ vars are substituted into SQL. Nice.) But
>> when I try to call it like this:
>>
>> * earliest record is call_recorddate(ver="'.'", order="asc")
>> or like this:
>> #+CALL: recorddate(ver="'.'", order="asc")
>>
>> and I try to export as LaTeX (or anything), I get
>> org-babel-ref-resolve: Reference 'recorddate' not found in this buffer
>>
>> Is this supposed to work?
>
section of the Org-mode manual.
,----
| It is also possible to evaluate named code blocks from anywhere in an
| Org mode buffer or an Org mode table. Live code blocks located in the
| current Org mode buffer or in the "Library of Babel" (see *note Library
| of Babel::) can be executed. Named code blocks can be executed with a
| separate '#+CALL:' line or inline within a block of text.
`----
There is no need to load code blocks in the same buffer into the library
of babel.
This example works for me evaluating code blocks in the same buffer
using call lines.
When I export this to e.g., html I get the following.
Call Example
echo "input is $input"Here's a simple call using a named argument.
input is fooIt also works with a positional argument.
input is bar
The call lines are replaced with their results as part of the export
process.
If the above doesn't work for you, then I imagine something is wrong
with your install.
--
Eric Schulte
http://cs.unm.edu/~eschulte
[Prev in Thread] | Current Thread | [Next in Thread] |