emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Org-mode as a metalanguage: calling SQL "functions"


From: Eric Abrahamsen
Subject: Re: [O] Org-mode as a metalanguage: calling SQL "functions"
Date: Tue, 02 Apr 2013 09:19:42 +0800
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3 (gnu/linux)

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?

You're supposed to "load" named blocks before you can call them with
#+CALL, etc. I'm a little surprised that it doesn't automatically find
blocks defined in the same buffer, but calling C-c C-v i (ie
org-babel-lob-ingest) and loading the present file should make
"recorddate" available for calling.

E




reply via email to

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