cmoog / vscode-sql-notebook

Open SQL files as VSCode Notebooks.
https://marketplace.visualstudio.com/items?itemName=cmoog.sqlnotebook
MIT License
129 stars 18 forks source link

Persist session across cells #30

Closed RollsChris closed 2 years ago

RollsChris commented 2 years ago

Hey

I'm having an issue where say if I create a temp table.. in the next cell its not accessible, I get the error: "Invalid object name '#temptable'.

I think this is possible as the standard SQL Server plugin is able to do this across queries?

Thanks

cmoog commented 2 years ago

Currently, when you connect in the sidebar we create a new connection pool. Then, each cell execution corresponds to a new connection from that pool. This model allows you to execute two cells concurrently since they're running through different connections.

To persist sessions across cells in the way you're describing, I think we'd need to use the same connection. Can your use case be solved by executing the related queries in the same cell?

RollsChris commented 2 years ago

hi, yes I could do that, but one of the main uses of the notebook ( for me at the moment) is to break a complex store procedure down and look at it step by step ( its also a good way of documenting it). This requires the state from the previous step to continue.

I think notebooks in other languages are the same and a connection per cell is more of an edge use?

Another thing id like to raise is persisting the notebook output etc.. this is also available in other notebooks.. for this though you might need to use your own custom file type :O. I could raise another ticket for this?