Preserve Comments in SQL Query
Pinned PlannedI would like to follow up this post regarding preserving comments while editing a query in the QueryEditor. There it is stated that this will be implemented in the next major release. Is this still valid?
-
Official comment
Hello, Christian.
I must admit that we haven't done this feature so far. I am terribly sorry for the inconvenience this cause everybody.
The major SQL parser update is delayed. Hopefully, we will get back to this feature in the second half of this year, but I can't promise you this.
Comment actions -
In Oracle, optimizer hints are realized as comments. You may take a look at this documentation. If I didn't miss anything, then it would only require some extensions to the existing SQL parser and no rework. The context of optimizer hints (i.e. to which item of the query they belong) is clearly specified.
At least this special kind of comment is indispensable for us. They reduce execution time by orders of magnitudes.
However, the specification shows a pattern about how to assign comments to an item in the SQL statement. From that pattern you could derive a general approach to assign comments to a part of a SQL statement on a best-effort basis.
Finally, even if you at least collect all comments at one place and render them at the beginning/end of the actual statement would already help us. Everything would be better then just forgetting them. :)
-
We have another approach that we assume is less invasive and easier to implement for you:
Add a "Comment" text-column in the GridView for editing the (sub-)query columns. Store the value of this comment in the LayoutXml.
That could be an intermediate step that would already help us a lot.
Next step could be to parse/render this from/to the final SQL as well, as discussed above.
What do you think?
-
Here is a simple SQL using hints for my comments and they "stick".
WITH c1 AS (SELECT /*+ -- CTE comments */ To_Char(:ENVIRO_NAME) AS ENVIRO_NAME,
To_Char(SYSDATE, 'YYYY-MM-DD') AS RUN_DATE
FROM DUAL)
SELECT /*+ -- MAIN comments */ c1.ENVIRO_NAME,
c1.RUN_DATE,
d0.CURR_DT
FROM (SELECT /*+ -- DERIVED comments */ SYSDATE AS CURR_DT
FROM c1) d0,
c1
Please sign in to leave a comment.
Comments
11 comments