The Run SQL Scripts tool provided by IBM i Access Client Solutions (ACS) does a great job of making an SQL statement more understandable with its color highlighting of SQL keywords and its formatting of the statement text.
I think you would agree that it would be great if that same
highlighting and formatting could ride along with your SQL statement text to
make it clearer to your peers when sharing your SQL via email, presentations, design docs, etc. This actually is possible - assuming that you have ACS 1.1.9.2
or later installed on your workstation.
The Run SQL Scripts auto-prompting
support for host variables and parameter markers got all the fanfare when
ACS 1.1.9.2 was released, but this version of ACS also delivered Rich Text Format copy
capabilities. Without this new capability, the following figure shows how the SQL
syntax highlighting disappears when an SQL statement text is copied from Run
SQL Scripts to a word processing tool or an email.
Now that the Run SQL Scripts copy captures the rich text format (i.e., color highlighting) associated with your SQL statement, you’ll be able to choose the highlighted Paste Option on the left as shown below to preserve the source statement format when performing a paste operation.
Once you select the highlighted Keep Source Formatting paste option in the prior figure, the SQL will be transformed back to the highlighted and formatted SQL statement as shown below. It's the same stylish presentation as Run SQL Scripts, but available in a different medium.
Hopefully, it’s now clear to how newer versions of ACS enable you to communicate and share your SQL statement text in a more comprehensible format.
Good stuff. Many programmers--and I mean many, MANY--fail to grasp the importance of "pretty" code. "Flowery" or pointlessly "*" or "--" -filled code doesn't count; we've all seen it. Having consistent formatting is important because it's much easier on your brain to read/parse code when the "shapes" (format) for coding a given feature (CASE, ORDER BY) are similar. Your brain will spot errors more easily by detecting something out of place. This is why tokenization (color coding) in Run SQL Scripts and RDi is so important--it helps your brain figure out what's not "as expected". As your SQL gets more complicated, the importance of formatting rises. In addition, I've found that modifying well-formatted code can be much easier when you set the formatting options to add new lines after commas and AND/OR's. When I do code reviews, messy SQL triggers a fail!
ReplyDelete