For better understanding, it's advisable to refer to both this documentation and the accompanying demo application. The demo application can be found on the ODC forge. Please refer to SQL Formatter Demo.
1. Install the latest component version
Check the OutSystems ODC Forge for the SQLFormatter component and ensure that the latest version is installed in your environment. If it's not installed, proceed with the installation. This component doesn't have any additional dependencies. You can also download and install the demo application at this time.
2. Manage your dependencies
Add a desired dependency in your application or library from the SQLFormatter library through manage dependencies and choose any of the Server Actions available (whichever suits you for your use-case).
3. Using the extension on your ODC app
You can call one of the directly the availble Server Actions:
FormatSQLColoringOnly: Colorizes a given SQL query in a html response without formatting options.
FormatSQL: Formats a given SQL query based on a subset of Formatting Options.
Drag and Drop or add the Server Action element you want to use that fits your use case.
In this case, we are using it in a client action that later can be use throughout your app.
Fill the Server Action parameters:
The mandatory SQL with the string to be formatted or coloured.
When using the desired FormattingOptions [not mandatory] you can set:
Indent String [text]: Strings used for indentation being the default “\t”
Spaces Per Tab [integer]: Number of spaces assigned for tabulation.
Max Line Width [integer]: Char maximum number per line.
New Statement Line Breaks [integer]: Number of Lines separating each statement.
New Clause Line Breaks [integer]: Number of Lines separating each clause.
Expand Comma Lists [boolean]: Sets commas in new lines if true, or just plain followed text if false.
Trailing Commas [boolean]: Sets trailing commas after attributes if selected as true.
Space After Comma [boolean]: If Expand Comma Lists is set as True, you also add a space in between commas and selected attributes when this property is selected.
Expand Boolean Expressions [boolean]: Expands booleans expressions on different lines.
Expand Case Statements [boolean]: Expands cases on different lines.
Expand Between Conditions [boolean]: Expands betweens with conditions on different lines.
Break Join On Sections [boolean]: Breaks join statements on different sections.
Uppercase Keywords [boolean]: Sets keywords as uppercase/lowercase.
HTML Coloring [boolean]: Sets the response as HTML with different styles for Operators, Functions,Comments,String,Keyword and ErrorHighlights
Note that the Server Action FormatSQLColoringOnly only requires the mandatory SQL with the string to be formatted or coloured.