From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Banel Subject: Re: orgtbl-to-sqlinsert Date: Sun, 02 Feb 2014 22:19:28 +0100 Message-ID: <52EEB660.5070308@free.fr> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47643) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WA4S1-0007R8-OY for emacs-orgmode@gnu.org; Sun, 02 Feb 2014 16:19:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WA4S0-00083E-M5 for emacs-orgmode@gnu.org; Sun, 02 Feb 2014 16:19:37 -0500 Received: from smtp5-g21.free.fr ([2a01:e0c:1:1599::14]:41419) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WA4S0-000838-1b for emacs-orgmode@gnu.org; Sun, 02 Feb 2014 16:19:36 -0500 Received: from [IPv6:2a01:e35:2e21:def0:f59c:55ab:14a0:ec7a] (unknown [IPv6:2a01:e35:2e21:def0:f59c:55ab:14a0:ec7a]) by smtp5-g21.free.fr (Postfix) with ESMTP id C0D7AD480DE for ; Sun, 2 Feb 2014 22:19:29 +0100 (CET) In-Reply-To: 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 Le 02/02/2014 21:09, Thomas S. Dye a =E9crit : > Aloha all, > > I'm expecting column names in the "foo( )" part of the INSERT statement= . > > I've done my best to understand > http://orgmode.org/worg/org-tutorials/multitarget-tables.org.html but > appear to have failed. > > Can someone help? > > *** Experiment with orgtbl-sqlinsert > > #+name: test-table > | one | two | > |-----+--------| > | 1 | Buckle | > | 2 | Shoe | > | 3 | Open | > | 4 | Door | > > #+name: test-bed > #+header: :var x=3Dtest-table > #+begin_src emacs-lisp > (require 'orgtbl-sqlinsert) > (orgtbl-to-sqlinsert x '(:sqlname "foo" :fmt (1 "%s"))) > #+end_src > > #+results: test-bed > : BEGIN TRANSACTION; > : INSERT INTO foo( ) VALUES ( 1 , 'Buckle' ); > : INSERT INTO foo( ) VALUES ( 2 , 'Shoe' ); > : INSERT INTO foo( ) VALUES ( 3 , 'Open' ); > : INSERT INTO foo( ) VALUES ( 4 , 'Door' ); > : COMMIT; > > All the best, > Tom Hi Thomas. I don't understand this behavior yet. But here is a workaround: try the #+ORGTBL: SEND feature: 1- Add a #+ORGTBL: SEND line 2- Add a BEGIN RECEIVE ORGTBL block 3- Type C-c C-c with cursor on the first pipe of the table --8<--------------------------->8-- #+ORGTBL: SEND faraway orgtbl-to-sqlinsert :sqlname "foo" :fmt (1 "%s") | one | two | |-----+--------| | 1 | Buckle | | 2 | Shoe | | 3 | Open | | 4 | Door | ;; BEGIN RECEIVE ORGTBL faraway BEGIN TRANSACTION; INSERT INTO foo( one, two ) VALUES ( 1 , 'Buckle' ); INSERT INTO foo( one, two ) VALUES ( 2 , 'Shoe' ); INSERT INTO foo( one, two ) VALUES ( 3 , 'Open' ); INSERT INTO foo( one, two ) VALUES ( 4 , 'Door' ); COMMIT; ;; END RECEIVE ORGTBL faraway --8<--------------------------->8--