DB2-Samples / db2jupyter

Db2 JSON Examples using Jupyter Notebooks
Apache License 2.0
32 stars 42 forks source link

Issue when using sql magic at cell level with DB2 extensions #1

Closed ecrooks closed 6 years ago

ecrooks commented 7 years ago

George,

I am using an example to show some of the differences between using SQL magic at the cell level vs. at the line level. I'm using three statements - successful statement; failing statement; successful statement; - and the behavior with the DB2 extensions and cell-level magic is not showing me the error at all, while I see the error without the db2 extensions. Here's what I see without the extensions: cell-level_sql_magic_nodb2extensions And here's what I see with them: cell-level_sql_magic_db2extensions

Using line-level SQL magic I get the expected results with the db2 extensions (just for reference): line-level_sql_magic_db2extensions

For full context, the notebooks I'm using are in https://github.com/ecrooks/db2_and_jupyter_notebooks/ - I'm using "2017_IDUG_EMEA-Db2_Extensions" and "2017_IDUG_EMEA"

Is this different behavior working as expected? Is it not recommended to use SQL magic at the cell level with the Db2 extensions?

Thanks, Ember

baklarz commented 6 years ago

The latest version I sent you corrects the error. I had to double-check what happens with the first %%sql block. My parser will take the strings that you pass to it and split them by semi colon. So in theory, the first sql statement would look like:

--sql magic at the cell level <nl> select * from syscat.tables;

I checked and luckily (not based on great programming on my part!) that it does get executed properly by Db2 since the gets properly parsed so it doesn't comment out the next line.