SQL Formatter
SQL code is much easier and faster to read and understand when it is formatted, especially when it is a long and complicated SQL statement or long SPL stored procedure written by other developers. Programmers spend 50% of their time just looking at source code. Formatting source code can make them more productive in this task, saving a significant amount of an IT department's time and budget.
Server Studio SQL Formatter has a number of advantages:
- Formats and beautifies individual Informix SQL statements, SQL scripts and SPL stored procedures and triggers with many formatting options
- Properly nested indentation makes it much easier to identify matching program blocks in stored procedures
- No more manual re-formatting of programs for readability
- A standard style used across an organization enables faster work because programmers know what to expect
- Code from other organizations can be easily standardized
- Fully integrated with SQL Editor
- Allows to format uncompleted SQL statements
To open SQL Formatter
Select required portion of SQL source in SQL Editor and choose Reformat SQL from popup menu or press Ctrl+T. SQL Formatter dialog box will be opened.
NOTE: If you do not select any text in SQL Editor and invoke Reformat SQL operation, all SQL statements in the editor will be formatted.
SQL Formatter Dialog Box
SQL Formatter dialog box has an option selection area in the left side and Preview panel in the right side. SQL source selected in SQL editor is immediately re-formatted according to the default options and resulting SQL is displayed in Preview window. Any further changes that you make in the formatter options are reflected in the Preview window. Once you are satisfied with a result of formatting, press OK button and source text in SQL editor will be substituted with the re-formatted text. Press Cancel button button, if you do not want to apply a new formatting to the source text in SQL Editor. If you want to undo changes that formatter applied to SQL editor, choose Undo from editors popup menu or press Ctrl+Z button.
SQL Formatter Options
General
Tab Size number of characters in tab for auto-indention
Max Line Length number of characters in one line of SQL code. It does not apply to comments and text constants. Those constructs are never broken to multiple lines. Formatter moves to new lines only reserved SQL keywords and identifiers.
Reserved Words choose case for SQL reserved words, such as SELECT, INSERT, UPDATE, etc.
Line Break Management
This section allows you to control how parameters lists are processed within individual SQL and SPL statements.
SELECT when checked, each parameter in SELECT parameter list, such as column name or expression, is displayed on a separate line.
INSERT INTO when checked , each column name in INSERT INTO table_name (column list) statement is displayed on a separate line.
VALUES when checked each value in INSERT INTO
VALUES (values list) is displayed on separate line.
CREATE TABLE when checked, each column name/datatype in CREATE TABLE statement is displayed on a separate line.
UPDATE ..SET when checked, each parameter in SET clause of UPDATE is displayed on separate line.
PROCEDURE when checked, each parameter/datatype in a list of CREATE PROCEDURE/FUNCTION statement is displayed on separate line. Each datatype is RETURNING clause is also displayed on a separate line.
CALL/EXECUTE when checked, each parameter in CALL/EXECUTE (parameter list) statement is displayed on a separate line.