Tabs in output

By default, when you press the tab-key in the editor, the indent is replaced by spaces. I wanted the generated code to contain tabs instead of spaces, so I have created the following code:
An Oracle Stored Function:

create or replace function tab_char return varchar2
is
begin
  return chr(9);
end tab_char;

In the cgml code I have created the following:

[SETALIAS]_tab[TO]{tab_char}

Now I can use the _tab variable to get my indents using the tab character:

BEGIN
{_tab}DBMS_OUTPUT.PUT_LINE('source indented using tabs');
END;

You can of course add more special characters this way and put the Oracle code in a package. Also, you can include the [SETALIAS] code in a setup script, so you have you special characters available at all times. And if you decide to change the name of the Oracle function, you only have to change a single call to this.
Also, don't forget to create synonyms and grant privileges if you want to use this function while generating from another schema.
Hope this is useful. Maybe we will see a CGML function for this in the future.

Leave a Reply

Your email address will not be published. Required fields are marked *