emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* sql can't export an empty table, gives error
@ 2014-12-23 22:34 Gary Oberbrunner
  2014-12-24 14:55 ` Gary Oberbrunner
  0 siblings, 1 reply; 2+ messages in thread
From: Gary Oberbrunner @ 2014-12-23 22:34 UTC (permalink / raw)
  To: Orgmode Mailing List

[-- Attachment #1: Type: text/plain, Size: 429 bytes --]

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?

-- 
Gary

[-- Attachment #2: Type: text/html, Size: 648 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: sql can't export an empty table, gives error
  2014-12-23 22:34 sql can't export an empty table, gives error Gary Oberbrunner
@ 2014-12-24 14:55 ` Gary Oberbrunner
  0 siblings, 0 replies; 2+ messages in thread
From: Gary Oberbrunner @ 2014-12-24 14:55 UTC (permalink / raw)
  To: Orgmode Mailing List


[-- 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-12-24 14:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-23 22:34 sql can't export an empty table, gives error Gary Oberbrunner
2014-12-24 14:55 ` Gary Oberbrunner

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).