Right-click a cell value and run a predefined parameterized query

[expired user #8144]'s profile image [expired user #8144] posted 8 years ago in Feature discussion Permalink
Wouldn't it be cool to say,
1. right-click one or multiple "cells" in a column of the datasheet (result of query or table content), and
2. have a "Quick Query" context menu item, listing in a submenu several predefined queries (defined upfront elsewhere i.e. under preferences)
3. that would pop up a dialog showing the query result

This would be very useful for easy lookups or testing potential joins, and gain quicker understanding of the dataset.
Building several queries for this is just cumbersome.

That would be a great differentiator (as is 'Quick Filter') vs e.g. TOAD Data Point (my favorite SQL builder).
ansgar's profile image ansgar posted 8 years ago Permalink
I don't really get what you are trying to achieve with that "query on one or multiple cells" thing. Do you want to update selected cells, or what's a real use-case here?
[expired user #8144]'s profile image [expired user #8144] posted 8 years ago Permalink

Ansgar,

  1. Say that you define under preferences one or multiple parameterized query statements e.g. SELECT * FROM HDR WHERE DOC IN (%1)
  2. then when you go on any resultset (from Query or Data tab), and you right-click on a cell/value, you would get the option to run the predefined subquery of your choice (defined in step 1) using the selected value from the cell as parameter e.g. cell/value is 180033 -> right-click and choose a defined subq which would run SELECT * FROM HDR WHERE DOC IN (180033). As HS knows the data type of the selected value, it would know to include quotes if applicable.
  3. the resultset of that subquery would display in a new window (not a full new HS instance).

As for the same but applied to multiple cells, I realize HS does not allow to select multiple cells in the datasheet. If it could, the subquery would receive as parameter the values separated by comma e.g. I select cells where values are 3, 6 and 98 --> the subq would run like SELECT * FROM HDR WHERE DOC IN (3,6,98).

Hope this makes sense.

ansgar's profile image ansgar posted 8 years ago Permalink

HeidiSQL has snippets, HeidiSQL can run parametrized queries and HeidiSQL has query tabs. Perhaps we can combine these things: Store some snippet which has this filecontent:

SELECT * FROM mytable WHERE id IN (:someparam)

Then, browse a table and rightclick a value like you described, which opens a submenu with all available snippets which have some parameter in it. Clicking on one snippet in that submenu would open up a new query tab with the parametrized snippet.

[expired user #8144]'s profile image [expired user #8144] posted 8 years ago Permalink

That would work well ! Ideally the new query tab would execute automatically (saves a F9), or that behavior could be control in the preferences.

The functionality would be very useful in data exploration where one goes from one table to the next and use the snippets to look up some information in known tables.

[expired user #11954]'s profile image [expired user #11954] posted 5 years ago Permalink

Hello. Is this method for binding data grid value to query parameter still functional? I have snippet with parameter, but after rightclick in data grid no show snippet menu :-( How substitute query parameter with cell value? Thank you.

ansgar's profile image ansgar posted 5 years ago Permalink

This feature was not yet implemented in any HeidiSQL version. Feel free to report it as a feature request in the bugtracker.

[expired user #11954]'s profile image [expired user #11954] posted 5 years ago Permalink

From your post in this thread (fourth from top) I figured that it is possible to transfer a value from a cell to a query. My mistake. Sorry.

Please login to leave a reply, or register at first.