Menu

#57 SQL code templates

open
nobody
5
2012-10-20
2005-12-16
Valentin
No

1) It's a good idea to implement SQL code templates in
SQL editor. For instance, for creating particular type
of stored procedure just by opening a template and
replacing parameters. As you see, I'm referencing
MSSQL Query Analyzer Again :)

Here is an example:

SET TERM ^ ;
CREATE OR ALTER PROCEDURE <table_name>_LIST
RETURNS (</table_name>

)
AS BEGIN
FOR SELECT
FROM <table_name>
INTO
DO BEGIN</table_name>

SUSPEND;
END
END^
SET TERM ; ^


In MSSQL Query Analyzer you define a parameter in a
template with <param_name>. In this example it is
<table_name>. Then, next time you open this template
you just open the parameter list, replace
corresponding values and you already have a lot of
typing done for you :)</table_name></param_name>

2) As I see, after right-clicking on the procedures
list in the object tree and choosing "Create new..."
the SQL editor is opened with a preset template. What
if we can apply our own templates when selecting this
command from menu? For example, by editing initial
template or by selecting new template from Preferences
window or by selecting another menu option and then
specifying the template file.

Best wishes,
Valentine.

Discussion

  • Valentin

    Valentin - 2005-12-16

    Logged In: YES
    user_id=1393292

    Of course, parameters and template files are good, but it
    takes time to implement these things. I think, the simplest
    and easily done change could be just removing hard-coded
    <new procedure=""> etc. templates to external files so that
    users can change them in a text editor.
    As for me, first of all, I would change 'CREATE PROCEDURE'
    to 'CREATE OR ALTER PROCEDURE' :)</new>

     
  • Anonymous

    Anonymous - 2005-12-17

    Logged In: YES
    user_id=577247

    CREATE OR ALTER PROCEDURE is not supported by Firebird 1.0,
    so it will stay this way for now.

    As for templates, there is a possible support for it, just
    needs some work. Take a look at HTML templates for property
    pages to get the idea (html-templates directory). It
    currently works for property pages, but it could be modified
    to work with anything else. Engine is there, we just need
    some modifications to make it available to SQL editor.

    Of course, this is an advanced feature, so don't expect it
    soon. We still have a long way to go with basic features
    (roadmap).

     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB