Hi Eric, * Config ** Some file to be ingested Let's say I have this code in a =my-lob.org= file: #+srcname: add-column-in-table(table="", column="", type="", nullability="") #+begin_src sql -- add column `$column' (if column does not exist yet) IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '$table' AND COLUMN_NAME = '$column') BEGIN ALTER TABLE $table ADD $column $type $nullability END #+end_src ** In .emacs ... which I ingest at Emacs startup through the lines: #+begin_src emacs-lisp (require 'ob-lob) (org-babel-lob-ingest "~/org/my-lob.org") #+end_src * Some other document ** Source params In some other document, I have a table with columns I'd like to add in a database: #+results: params | table | column | type | nullability | |---------+----------------+-------------+-------------| | dossier | pfiResetDate | date | NULL | | dossier | pfiResetOprID | tinyint | NULL | | dossier | pfiResetOprNom | varchar(64) | NULL | Normally, I could call statements like this: #+call: add-column-in-table(table=params[2,0], column=params[2,1], type=params[2,2], nullability=params[2,3]) But... ** Expand code is failing =C-c C-v C-v= does generate an error: setf: Wrong type argument: consp, nil #+begin_src text Debugger entered--Lisp error: (wrong-type-argument consp nil) setcar(nil ((:cache . "") (:comments . "") (:exports . "") (:noweb . "") (:padline . "") (:results . "") (:shebang . "") (:tangle . ""))) (setf (nth 2 info) (sort (org-babel-merge-params ... params) (lambda ... ...))) (let* ((info ...) (lang ...) (params ...) (body ...) (expand-cmd ...) (assignments-cmd ...) (expanded ...)) (org-edit-src-code nil expanded (concat "*Org-Babel Preview " ... "[ " lang " ]*"))) org-babel-expand-src-block() call-interactively(org-babel-expand-src-block nil nil) #+end_src This stays very unclear to me... ** Execute code is failing By the way, =C-c C-v C-e= returns as well an error: let: Wrong type argument: stringp, nil This is explainable: that's because the SQL =engine= is not known (not given neither in the header of the code block, neither anywhere in this file). #+begin_src text Debugger entered--Lisp error: (wrong-type-argument stringp nil) intern(nil) (let ((--cl-var-- ...)) (cond (... ...) (... ...) (... ...) (t ...))) (case (intern engine) ((quote msosql) (format "osql %s -s \" \" -i %s -o %s" ... ... ...)) ((quote mysql) (format "mysql %s < %s > %s" ... ... ...)) ((quote postgresql) (format "psql -A -P footer=off -F \" \" -f %s -o %s %s" ... ... ...)) (t (error "no support for the %s sql engine" engine))) (let* ((result-params ...) (cmdline ...) (engine ...) (in-file ...) (out-file ...) (header-delim "") (command ...)) (with-temp-file in-file (insert ...)) (message command) (shell-command command) (if (or ... ... ... ... ...) (with-temp-buffer ...) (with-temp-buffer ... ... ...))) org-babel-execute:sql("-- add column `$column' (if column does not exist yet)\nIF NOT EXISTS (SELECT *\n FROM INFORMATION_SCHEMA.COLUMNS\n WHERE TABLE_NAME = '$table'\n AND COLUMN_NAME = '$column')\nBEGIN\n ALTER TABLE $table\n ADD $column $type $nullability\nEND" ((:var table . "dossier") (:var column . "pfiResetDate") (:var type . "date") (:var nullability . "NULL") (:colname-names) (:rowname-names) (:result-params "silent" "replace") (:result-type . value) (:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "silent") (:padnewline . "yes") (:hlines . "no") (:session . "none") (:result-type . value) (:result-params "replace") (:rowname-names) (:colname-names))) #+end_src Though, I guess we should have a proper manner to report that some necessary arguments are missing, instead of failing with a unclear message. ** Other weirdnesses While the variable =org-babel-library-of-babel= contains the ingested code (here, of =add-column-in-table=), the variable =org-babel-lob-files= is =nil=!? ** Speed commands Speed commands don't work on the =#+call= lines. If I press =v= or =e=, they're inserted verbatim. Can you help me understand the 1^st point of these 4? Thanks a lot!! Best regards, Seb -- Sebastien Vauban
Hi Seb, This is a minor point, but would you mind structuring your emails with an introduction of pure-prose (no embedded examples), saving the examples for the end (footnotes work well for this). I often find it disjointing to try to ingest large code example while simultaneously trying to figure out the high-level point of the email. As to this specific question... I am not sure where you are trying to expand a code block. It seems as if you are trying to expand a call line, but I do not believe that is supposed to be possible. Best -- Eric "Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes: > Hi Eric, > > * Config > > ** Some file to be ingested > > Let's say I have this code in a =my-lob.org= file: > > #+srcname: add-column-in-table(table="", column="", type="", nullability="") > #+begin_src sql > -- add column `$column' (if column does not exist yet) > IF NOT EXISTS (SELECT * > FROM INFORMATION_SCHEMA.COLUMNS > WHERE TABLE_NAME = '$table' > AND COLUMN_NAME = '$column') > BEGIN > ALTER TABLE $table > ADD $column $type $nullability > END > #+end_src > > ** In .emacs > > ... which I ingest at Emacs startup through the lines: > > #+begin_src emacs-lisp > (require 'ob-lob) > (org-babel-lob-ingest "~/org/my-lob.org") > #+end_src > > * Some other document > > ** Source params > > In some other document, I have a table with columns I'd like to add in a > database: > > #+results: params > | table | column | type | nullability | > |---------+----------------+-------------+-------------| > | dossier | pfiResetDate | date | NULL | > | dossier | pfiResetOprID | tinyint | NULL | > | dossier | pfiResetOprNom | varchar(64) | NULL | > > Normally, I could call statements like this: > > #+call: add-column-in-table(table=params[2,0], column=params[2,1], type=params[2,2], nullability=params[2,3]) > > But... > > ** Expand code is failing > > =C-c C-v C-v= does generate an error: > > setf: Wrong type argument: consp, nil > > #+begin_src text > Debugger entered--Lisp error: (wrong-type-argument consp nil) > setcar(nil ((:cache . "") (:comments . "") (:exports . "") (:noweb . "") (:padline . "") (:results . "") (:shebang . "") (:tangle . ""))) > (setf (nth 2 info) (sort (org-babel-merge-params ... params) (lambda ... ...))) > (let* ((info ...) (lang ...) (params ...) (body ...) (expand-cmd ...) (assignments-cmd ...) (expanded ...)) (org-edit-src-code nil expanded (concat "*Org-Babel Preview " ... "[ " lang " ]*"))) > org-babel-expand-src-block() > call-interactively(org-babel-expand-src-block nil nil) > #+end_src > > This stays very unclear to me... > > ** Execute code is failing > > By the way, =C-c C-v C-e= returns as well an error: > > let: Wrong type argument: stringp, nil > > This is explainable: that's because the SQL =engine= is not known (not given > neither in the header of the code block, neither anywhere in this file). > > #+begin_src text > Debugger entered--Lisp error: (wrong-type-argument stringp nil) > intern(nil) > (let ((--cl-var-- ...)) (cond (... ...) (... ...) (... ...) (t ...))) > (case (intern engine) ((quote msosql) (format "osql %s -s \" \" -i %s -o %s" ... ... ...)) ((quote mysql) (format "mysql %s < %s > %s" ... ... ...)) ((quote postgresql) (format "psql -A -P footer=off -F \" \" -f %s -o %s %s" ... ... ...)) (t (error "no support for the %s sql engine" engine))) > (let* ((result-params ...) (cmdline ...) (engine ...) (in-file ...) (out-file ...) (header-delim "") (command ...)) (with-temp-file in-file (insert ...)) (message command) (shell-command command) (if (or ... ... ... ... ...) (with-temp-buffer ...) (with-temp-buffer ... ... ...))) > org-babel-execute:sql("-- add column `$column' (if column does not exist yet)\nIF NOT EXISTS (SELECT *\n FROM INFORMATION_SCHEMA.COLUMNS\n WHERE TABLE_NAME = '$table'\n AND COLUMN_NAME = '$column')\nBEGIN\n ALTER TABLE $table\n ADD $column $type $nullability\nEND" ((:var table . "dossier") (:var column . "pfiResetDate") (:var type . "date") (:var nullability . "NULL") (:colname-names) (:rowname-names) (:result-params "silent" "replace") (:result-type . value) (:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "silent") (:padnewline . "yes") (:hlines . "no") (:session . "none") (:result-type . value) (:result-params "replace") (:rowname-names) (:colname-names))) > #+end_src > > Though, I guess we should have a proper manner to report that some necessary > arguments are missing, instead of failing with a unclear message. > > ** Other weirdnesses > > While the variable =org-babel-library-of-babel= contains the ingested code > (here, of =add-column-in-table=), the variable =org-babel-lob-files= is =nil=!? > > ** Speed commands > > Speed commands don't work on the =#+call= lines. If I press =v= or =e=, they're > inserted verbatim. > > Can you help me understand the 1^st point of these 4? Thanks a lot!! > > Best regards, > Seb -- Eric Schulte http://cs.unm.edu/~eschulte/
Hi Eric, Eric Schulte wrote: > This is a minor point, but would you mind structuring your emails with > an introduction of pure-prose (no embedded examples), saving the > examples for the end (footnotes work well for this). I often find it > disjointing to try to ingest large code example while simultaneously > trying to figure out the high-level point of the email. Point noted. OK. > As to this specific question... I am not sure where you are trying to > expand a code block. It seems as if you are trying to expand a call > line, but I do not believe that is supposed to be possible. As for any other code block, all I want is to see its expanded (instantiated) version before I run it. Is this not doable when you call the code block remotely (I mean: from a #+call line, instead of from the code block itself)? If not, does that mean we better not put code block into the lob, when we're interested by having a look at their expanded form? Best regards, Seb > "Sebastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes: > >> Hi Eric, >> >> * Config >> >> ** Some file to be ingested >> >> Let's say I have this code in a =my-lob.org= file: >> >> #+srcname: add-column-in-table(table="", column="", type="", nullability="") >> #+begin_src sql >> -- add column `$column' (if column does not exist yet) >> IF NOT EXISTS (SELECT * >> FROM INFORMATION_SCHEMA.COLUMNS >> WHERE TABLE_NAME = '$table' >> AND COLUMN_NAME = '$column') >> BEGIN >> ALTER TABLE $table >> ADD $column $type $nullability >> END >> #+end_src >> >> ** In .emacs >> >> ... which I ingest at Emacs startup through the lines: >> >> #+begin_src emacs-lisp >> (require 'ob-lob) >> (org-babel-lob-ingest "~/org/my-lob.org") >> #+end_src >> >> * Some other document >> >> ** Source params >> >> In some other document, I have a table with columns I'd like to add in a >> database: >> >> #+results: params >> | table | column | type | nullability | >> |---------+----------------+-------------+-------------| >> | dossier | pfiResetDate | date | NULL | >> | dossier | pfiResetOprID | tinyint | NULL | >> | dossier | pfiResetOprNom | varchar(64) | NULL | >> >> Normally, I could call statements like this: >> >> #+call: add-column-in-table(table=params[2,0], column=params[2,1], type=params[2,2], nullability=params[2,3]) >> >> But... >> >> ** Expand code is failing >> >> =C-c C-v C-v= does generate an error: >> >> setf: Wrong type argument: consp, nil >> >> #+begin_src text >> Debugger entered--Lisp error: (wrong-type-argument consp nil) >> setcar(nil ((:cache . "") (:comments . "") (:exports . "") (:noweb . "") (:padline . "") (:results . "") (:shebang . "") (:tangle . ""))) >> (setf (nth 2 info) (sort (org-babel-merge-params ... params) (lambda ... ...))) >> (let* ((info ...) (lang ...) (params ...) (body ...) (expand-cmd ...) (assignments-cmd ...) (expanded ...)) (org-edit-src-code nil expanded (concat "*Org-Babel Preview " ... "[ " lang " ]*"))) >> org-babel-expand-src-block() >> call-interactively(org-babel-expand-src-block nil nil) >> #+end_src >> >> This stays very unclear to me... >> >> ** Execute code is failing >> >> By the way, =C-c C-v C-e= returns as well an error: >> >> let: Wrong type argument: stringp, nil >> >> This is explainable: that's because the SQL =engine= is not known (not given >> neither in the header of the code block, neither anywhere in this file). >> >> #+begin_src text >> Debugger entered--Lisp error: (wrong-type-argument stringp nil) >> intern(nil) >> (let ((--cl-var-- ...)) (cond (... ...) (... ...) (... ...) (t ...))) >> (case (intern engine) ((quote msosql) (format "osql %s -s \" \" -i %s -o %s" ... ... ...)) ((quote mysql) (format "mysql %s < %s > %s" ... ... ...)) ((quote postgresql) (format "psql -A -P footer=off -F \" \" -f %s -o %s %s" ... ... ...)) (t (error "no support for the %s sql engine" engine))) >> (let* ((result-params ...) (cmdline ...) (engine ...) (in-file ...) (out-file ...) (header-delim "") (command ...)) (with-temp-file in-file (insert ...)) (message command) (shell-command command) (if (or ... ... ... ... ...) (with-temp-buffer ...) (with-temp-buffer ... ... ...))) >> org-babel-execute:sql("-- add column `$column' (if column does not exist yet)\nIF NOT EXISTS (SELECT *\n FROM INFORMATION_SCHEMA.COLUMNS\n WHERE TABLE_NAME = '$table'\n AND COLUMN_NAME = '$column')\nBEGIN\n ALTER TABLE $table\n ADD $column $type $nullability\nEND" ((:var table . "dossier") (:var column . "pfiResetDate") (:var type . "date") (:var nullability . "NULL") (:colname-names) (:rowname-names) (:result-params "silent" "replace") (:result-type . value) (:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "silent") (:padnewline . "yes") (:hlines . "no") (:session . "none") (:result-type . value) (:result-params "replace") (:rowname-names) (:colname-names)) ) > >> #+end_src >> >> Though, I guess we should have a proper manner to report that some necessary >> arguments are missing, instead of failing with a unclear message. >> >> ** Other weirdnesses >> >> While the variable =org-babel-library-of-babel= contains the ingested code >> (here, of =add-column-in-table=), the variable =org-babel-lob-files= is =nil=!? >> >> ** Speed commands >> >> Speed commands don't work on the =#+call= lines. If I press =v= or =e=, they're >> inserted verbatim. >> >> Can you help me understand the 1^st point of these 4? Thanks a lot!! -- Sebastien Vauban
> >> As to this specific question... I am not sure where you are trying to >> expand a code block. It seems as if you are trying to expand a call >> line, but I do not believe that is supposed to be possible. > > As for any other code block, all I want is to see its expanded (instantiated) > version before I run it. > > Is this not doable when you call the code block remotely (I mean: from > a #+call line, instead of from the code block itself)? > That is correct. There is no reason (that I can think of at the moment) why this functionality could not be added, but currently the code block preview functionality expects to be called from within a code block. > > If not, does that mean we better not put code block into the lob, when we're > interested by having a look at their expanded form? > Yes, given the current state of affairs that is correct. Best -- Eric > > Best regards, > Seb > >> "Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes: >> >>> Hi Eric, >>> >>> * Config >>> >>> ** Some file to be ingested >>> >>> Let's say I have this code in a =my-lob.org= file: >>> >>> #+srcname: add-column-in-table(table="", column="", type="", nullability="") >>> #+begin_src sql >>> -- add column `$column' (if column does not exist yet) >>> IF NOT EXISTS (SELECT * >>> FROM INFORMATION_SCHEMA.COLUMNS >>> WHERE TABLE_NAME = '$table' >>> AND COLUMN_NAME = '$column') >>> BEGIN >>> ALTER TABLE $table >>> ADD $column $type $nullability >>> END >>> #+end_src >>> >>> ** In .emacs >>> >>> ... which I ingest at Emacs startup through the lines: >>> >>> #+begin_src emacs-lisp >>> (require 'ob-lob) >>> (org-babel-lob-ingest "~/org/my-lob.org") >>> #+end_src >>> >>> * Some other document >>> >>> ** Source params >>> >>> In some other document, I have a table with columns I'd like to add in a >>> database: >>> >>> #+results: params >>> | table | column | type | nullability | >>> |---------+----------------+-------------+-------------| >>> | dossier | pfiResetDate | date | NULL | >>> | dossier | pfiResetOprID | tinyint | NULL | >>> | dossier | pfiResetOprNom | varchar(64) | NULL | >>> >>> Normally, I could call statements like this: >>> >>> #+call: add-column-in-table(table=params[2,0], column=params[2,1], type=params[2,2], nullability=params[2,3]) >>> >>> But... >>> >>> ** Expand code is failing >>> >>> =C-c C-v C-v= does generate an error: >>> >>> setf: Wrong type argument: consp, nil >>> >>> #+begin_src text >>> Debugger entered--Lisp error: (wrong-type-argument consp nil) >>> setcar(nil ((:cache . "") (:comments . "") (:exports . "") (:noweb . "") (:padline . "") (:results . "") (:shebang . "") (:tangle . ""))) >>> (setf (nth 2 info) (sort (org-babel-merge-params ... params) (lambda ... ...))) >>> (let* ((info ...) (lang ...) (params ...) (body ...) (expand-cmd ...) (assignments-cmd ...) (expanded ...)) (org-edit-src-code nil expanded (concat "*Org-Babel Preview " ... "[ " lang " ]*"))) >>> org-babel-expand-src-block() >>> call-interactively(org-babel-expand-src-block nil nil) >>> #+end_src >>> >>> This stays very unclear to me... >>> >>> ** Execute code is failing >>> >>> By the way, =C-c C-v C-e= returns as well an error: >>> >>> let: Wrong type argument: stringp, nil >>> >>> This is explainable: that's because the SQL =engine= is not known (not given >>> neither in the header of the code block, neither anywhere in this file). >>> >>> #+begin_src text >>> Debugger entered--Lisp error: (wrong-type-argument stringp nil) >>> intern(nil) >>> (let ((--cl-var-- ...)) (cond (... ...) (... ...) (... ...) (t ...))) >>> (case (intern engine) ((quote msosql) (format "osql %s -s \" \" -i %s -o %s" ... ... ...)) ((quote mysql) (format "mysql %s < %s > %s" ... ... ...)) ((quote postgresql) (format "psql -A -P footer=off -F \" \" -f %s -o %s %s" ... ... ...)) (t (error "no support for the %s sql engine" engine))) >>> (let* ((result-params ...) (cmdline ...) (engine ...) (in-file ...) (out-file ...) (header-delim "") (command ...)) (with-temp-file in-file (insert ...)) (message command) (shell-command command) (if (or ... ... ... ... ...) (with-temp-buffer ...) (with-temp-buffer ... ... ...))) >>> org-babel-execute:sql("-- add column `$column' (if column does not exist yet)\nIF NOT EXISTS (SELECT *\n FROM INFORMATION_SCHEMA.COLUMNS\n WHERE TABLE_NAME = '$table'\n AND COLUMN_NAME = '$column')\nBEGIN\n ALTER TABLE $table\n ADD $column $type $nullability\nEND" ((:var table . "dossier") (:var column . "pfiResetDate") (:var type . "date") (:var nullability . "NULL") (:colname-names) (:rowname-names) (:result-params "silent" "replace") (:result-type . value) (:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "silent") (:padnewline . "yes") (:hlines . "no") (:session . "none") (:result-type . value) (:result-params "replace") (:rowname-names) (:colname-names) )) >> >>> #+end_src >>> >>> Though, I guess we should have a proper manner to report that some necessary >>> arguments are missing, instead of failing with a unclear message. >>> >>> ** Other weirdnesses >>> >>> While the variable =org-babel-library-of-babel= contains the ingested code >>> (here, of =add-column-in-table=), the variable =org-babel-lob-files= is =nil=!? >>> >>> ** Speed commands >>> >>> Speed commands don't work on the =#+call= lines. If I press =v= or =e=, they're >>> inserted verbatim. >>> >>> Can you help me understand the 1^st point of these 4? Thanks a lot!! -- Eric Schulte http://cs.unm.edu/~eschulte/