emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Gary Oberbrunner <garyo@oberbrunner.com>
To: Orgmode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: sql can't export an empty table, gives error
Date: Wed, 24 Dec 2014 09:55:34 -0500	[thread overview]
Message-ID: <CAFChFyiy2vEU2g_VLYtiRd5YMUBV0KU0OqpgfdV0OY80KNsWkw@mail.gmail.com> (raw)
In-Reply-To: <CAFChFyh_Yd2XPSS9izyo95g23cKgGpTpHp4KrXXqgA2wpbbJoQ@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 598 bytes --]

On Tue, Dec 23, 2014 at 5:34 PM, Gary Oberbrunner <garyo@oberbrunner.com>
wrote:

> If you try to export this document:
>
> #+BEGIN_SRC sql :exports both
>  select 1 limit 0;
> #+END_SRC
>
> It fails to export with an error in *Messages*:
>  user-error: Empty table - created default table
> It also stops processing the document at that point.
> (That SQL code produces no output but is not a SQL error.)
>
> I'd prefer if it would just leave that empty (missing) table out, and keep
> going.  Is there any way to do that?
>

Here's a simple patch to fix this, if people are interested.

-- 
Gary

[-- Attachment #1.2: Type: text/html, Size: 1171 bytes --]

[-- Attachment #2: 0001-Allow-empty-table-creation-on-export-rather-than-giv.patch --]
[-- Type: application/octet-stream, Size: 1011 bytes --]

From e56ebfe77029085c2f1af49fe6eb943191b8e184 Mon Sep 17 00:00:00 2001
From: Gary Oberbrunner <garyo@genarts.com>
Date: Wed, 24 Dec 2014 09:52:54 -0500
Subject: [PATCH] Allow empty table creation on export, rather than giving
 error.

This is useful with SQL which can produce no results sometimes.
---
 lisp/org-table.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/org-table.el b/lisp/org-table.el
index 6b33eda..8168b58 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -796,7 +796,8 @@ When nil, simply write \"#ERROR\" in corrupted fields.")
       (error
        (kill-region beg end)
        (org-table-create org-table-default-size)
-       (user-error "Empty table - created default table")))
+       (setq maxfields 0)
+       (org-display-warning "Empty table - created default table")))
     ;; A list of empty strings to fill any short rows on output
     (setq emptystrings (make-list maxfields ""))
     ;; Check for special formatting.
-- 
1.9.5.msysgit.0


      reply	other threads:[~2014-12-24 14:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-23 22:34 sql can't export an empty table, gives error Gary Oberbrunner
2014-12-24 14:55 ` Gary Oberbrunner [this message]

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=CAFChFyiy2vEU2g_VLYtiRd5YMUBV0KU0OqpgfdV0OY80KNsWkw@mail.gmail.com \
    --to=garyo@oberbrunner.com \
    --cc=emacs-orgmode@gnu.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).