From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: Org-mode as a metalanguage: calling SQL "functions" Date: Tue, 02 Apr 2013 09:19:42 +0800 Message-ID: <87vc85raoh.fsf@ericabrahamsen.net> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:55085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMpnX-0003w3-0m for emacs-orgmode@gnu.org; Mon, 01 Apr 2013 21:14:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UMpnT-0007xN-Af for emacs-orgmode@gnu.org; Mon, 01 Apr 2013 21:14:02 -0400 Received: from plane.gmane.org ([80.91.229.3]:59690) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMpnT-0007w9-3v for emacs-orgmode@gnu.org; Mon, 01 Apr 2013 21:13:59 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UMpno-0007hr-31 for emacs-orgmode@gnu.org; Tue, 02 Apr 2013 03:14:20 +0200 Received: from 221.216.161.222 ([221.216.161.222]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 02 Apr 2013 03:14:20 +0200 Received: from eric by 221.216.161.222 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 02 Apr 2013 03:14:20 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Gary Oberbrunner 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