SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
[11.3.279 Pro] - Code Snippet Code Formatting Style

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
[11.3.279 Pro] - Code Snippet Code Formatting Style
Author Message
gemisigo



Joined: 11 Mar 2010
Posts: 2115

Post [11.3.279 Pro] - Code Snippet Code Formatting Style Reply with quote
The Code Formatting Style set for some of my snippets does not seem to be applied to the result of the snippet. For example, the simple test snippet
Code:

select 1 as a, 2 as b, 3 as c;

does get formatted to
Code:

SELECT 1  AS a
      ,2  AS b
      ,3  AS c;


But when the generated code for the slightly more complicated
Code:

$PROMPT(cursor_name,Enter cursor name (it will be prefixed with 'cur_'),my_cursor,Declare cursor)$
$PROMPT(scope,Cursor scope?,1,Declare cursor, " " LOCAL GLOBAL,"I don't care!" Local Global)$
$PROMPT(direction,Cursor direction?,1,Declare cursor, " " FORWARD_ONLY SCROLL,"I don't care!" "Forward only" Scrolling)$
$PROMPT(type,Cursor type?,2,Declare cursor, " " DYNAMIC FAST_FORWARD KEYSET STATIC,"I don't care!" Dynamic "Fast forward" Keyset Static)$
$PROMPT(lock,Lock mode?,2,Declare cursor, " " OPTIMISTIC READ_ONLY SCROLL_LOCKS,"I don't care :)" Optimistic "Read only" "Scroll locks")$
$PROMPT(typewarning,Type warning?,,Declare cursor, " " TYPE_WARNING,"Never heard of that o_O" "Yes\,please!")$
$PROMPT(update,Wanna update anything?,1,Declare cursor,"FOR UPDATE" " " "FOR UPDATE OF","Aye\,everything!" "Nay\,thanks!" "Yep\,here and there!")$

DECLARE @_$COLUMNS(vertical,types)$;

DECLARE cur_$cursor_name$ CURSOR
   $scope$ $direction$ $type$ $lock$ $typewarning$
FOR
SELECT cur.$COLUMNS(vertical)$
FROM $OBJECT(table, view, mview, tblFunc)$ as cur
$update$;

OPEN cur_$cursor_name$;

FETCH FROM cur_$cursor_name$ INTO @_$COLUMNS$;

WHILE @@FETCH_STATUS = 0
BEGIN
-- *********************** Cursor logic starts here *********************************************************************     
   |
-- *********************** Cursor logic ends here ***********************************************************************     
   FETCH FROM cur_$cursor_name$ INTO @_$COLUMNS$
END;

CLOSE cur_$cursor_name$;
DEALLOCATE cur_$cursor_name$;


is executed for the table
Code:

CREATE TABLE x (a INT, b VARCHAR(10), c DECIMAL(10,3));


the code that is inserted is not formatted at all.

This is how it looks when inserted:
Code:

DECLARE @[_a] int,
        @[_b] varchar(10),
        @[_c] decimal(10,3);

DECLARE cur_my_cursor CURSOR
   LOCAL FORWARD_ONLY FAST_FORWARD READ_ONLY 
FOR
SELECT cur.[a],
       cur.[b],
       cur.[c]
FROM [x] as cur
 ;

OPEN cur_my_cursor;

FETCH FROM cur_my_cursor INTO @[_a], @[_b], @[_c];

WHILE @@FETCH_STATUS = 0
BEGIN
-- *********************** Cursor logic starts here *********************************************************************     
   
-- *********************** Cursor logic ends here ***********************************************************************     
   FETCH FROM cur_my_cursor INTO @[_a], @[_b], @[_c]
END;

CLOSE cur_my_cursor;
DEALLOCATE cur_my_cursor;


And this is how it should look like and how it does after manually applying the same formatting rules that are set for the snippet (disregard the fact that the variable names should not contain brackets as delimiters, that's another issue):
Code:

DECLARE @     [_a] INT
       ,@     [_b] VARCHAR(10)
       ,@     [_c] DECIMAL(10 ,3)
;

DECLARE cur_my_cursor CURSOR LOCAL FORWARD_ONLY FAST_FORWARD READ_ONLY
FOR
    SELECT cur.[a]
          ,cur.[b]
          ,cur.[c]
        FROM [x] AS cur;

OPEN cur_my_cursor
;

FETCH FROM cur_my_cursor
    INTO @[_a]
         ,@[_b]
         ,@[_c];

WHILE @@FETCH_STATUS = 0
BEGIN
    -- *********************** Cursor logic starts here *********************************************************************     
   
    -- *********************** Cursor logic ends here ***********************************************************************     
    FETCH FROM cur_my_cursor
        INTO @[_a]
             ,@[_b]
             ,@[_c]
END
;

CLOSE cur_my_cursor
;
DEALLOCATE cur_my_cursor
;

Mon Sep 28, 2020 5:51 am View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.