SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Custom formatting doesn't work with "Code Formatting&qu

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
Custom formatting doesn't work with "Code Formatting&qu
Author Message
KUGS4C



Joined: 07 Feb 2008
Posts: 3
Country: Kazakhstan

Post Custom formatting doesn't work with "Code Formatting&qu Reply with quote
Hiho,

The default for the INSERT-snippet in MSSQL is:
<code>
INSERT ...
(
...,
...
)
VALUES
(
...,
...
)
</code>

I've changed that to:
<code>
INSERT ...
(
...
, ...
)
VALUES
(
...
, ...
)
</code>

But it appears that the auto-completion code works seperately from the code formatting tool.
Thu Feb 07, 2008 3:42 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7839

Post Reply with quote
That's right. Code snippets have nothing to do with auto-completion. To get a better idea of code snippets are, type cfetch and then press Ctrl+Enter, pick some table. To use your own INSERT snippet, type ins and then Ctrl+Enter
Thu Feb 07, 2008 3:58 pm View user's profile Send private message
KUGS4C



Joined: 07 Feb 2008
Posts: 3
Country: Kazakhstan

Post Reply with quote
Thank you for your reply.

I would really have preferred if code completion were customized according to code formatting.

Perhaps this is something you consider interesting?
Fri Feb 08, 2008 1:09 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7839

Post Reply with quote
I can offer a solution for that.

1. Disable code completion feature for DDL statements (uncheck Auto Expand SQL Code option)
2. Create a snippet with the name INSERT and set the activation key to be a space character. Set the snippet case-sensitive option to False.
3. In the snippet, code what you want it to do. You may use to use macro-variables like $COLUMNS$ or $OBJECT$. There are plenty of examples available in the existing pre-configured snippets.


Hope this helps.
Fri Feb 08, 2008 1:24 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7839

Post Reply with quote
An alternative method is to use the reformat Ctrl+F11 function to convert the generated SQL as required, for example, to put commas in front.
Fri Feb 08, 2008 1:30 pm View user's profile Send private message
KUGS4C



Joined: 07 Feb 2008
Posts: 3
Country: Kazakhstan

Post Reply with quote
SysOp wrote:

Hope this helps.


Thanks, but it seems the macro-variable $COLUMNS$ is expands to a comma-and-space separated list.

As in this example:
Code:

CREATE TABLE foo (id int, bar int)


INSERT INTO foo
(
   id, bar
   , id, bar
)
   SELECT


, where I defined the snippet to be:
Code:

INSERT INTO $OBJECT$
(
   $COLUMNS$
   , $COLUMNS$
)
   SELECT |


CTRL+F11 works, of course, but it is a tad tiring to have to press this key-combination after every statement.

Possibly the application could automatically run a reformat of the newly-generated code after it is inserted in the editor.
Sat Feb 09, 2008 8:14 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7839

Post Reply with quote
At the time of the previous post I was thinking about

Code:
INSERT INTO $OBJECT$
(
  ,$COLUMNS$
)
SELECT |


Yet, it appears that symbols adjacent to macro variables have special treatment. Basically they are treated as user-defined prefixes and/or suffixes for auto-generated object and column names. I am going to submit an enhancement request for snippets to support vertical column format and positional control for commas.
Sat Feb 09, 2008 11:35 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.