 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
[SA 6 Beta] - Code formatting, commas in stored procedures |
|
The default formatting rule that comes with SA does not work properly. When formatting stored procedures, SA pays no heed to setting Commas=stacked(leading), thus
 |
 |
CREATE PROCEDURE dbo.sp_aoeu @p1 INT, @p2 NUMERIC, @p3 INT
AS
BEGIN
-- ...
RETURN @@ERROR
END
GO
|
ends up formatted stacked(trailing) like this:
 |
 |
CREATE PROCEDURE dbo.sp_aoeu
@p1 INT,
@p2 NUMERIC,
@p3 INT
AS
BEGIN
RETURN @@ERROR
END
GO
|
I tried to change the default setting to
 |
 |
CREATE PROCEDURE ...
@...
,@...
WITH ...
,...
AS
<stmtList>
GO
|
but it only made things worse. The result:
 |
 |
CREATE PROCEDURE dbo.sp_aoeu
@p1 INT
,
@p2 NUMERIC
,
@p3 INT
AS
BEGIN
RETURN @@ERROR
END
GO
|
|
|
Fri Jul 22, 2011 5:34 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Please change formatting rule for CREATE PROCEDURE to
 |
 |
CREATE PROCEDURE ...
(
...
,@...
,@...
)
WITH ...
,...
AS
<stmtList>
GO |
To use that rule, please use brackets around procedure parameters as in the ANSI and SQL standards. That should do what you want.
 |
 |
CREATE PROCEDURE dbo.sp_aoeu (@p1 INT, @p2 NUMERIC, @p3 INT)
AS
BEGIN
-- ...
RETURN @@ERROR
END
GO |
|
|
Fri Jul 22, 2011 11:24 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
Yes, I figured that out through try and err and already altered my snippet that creates procedures but I've got a vast number of different scripts written by other developers that still use this syntax (and it's quite difficult to convince them to change habits :) Not to mention that it also affects existing procedures when altering them.
I also tried to remove @-s but did not work. Result was:
 |
 |
CREATE PROCEDURE dbo.sp_aoeu
@p1 INT
,...@p2 NUMERIC
,...@p3 INT
AS
BEGIN
RETURN @@ERROR
END
GO
|
Is this going to be fixed? It worked in previous version. If stays this way I'll have to create a pre-processor to modify all create/alter procedure script fragments to use the new syntax. It can be tedious to scan some several tens of thousand lines to check if formatting the script would break the code or not.
|
|
Fri Jul 22, 2011 12:22 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Are you saying this is a behavioral change? Can you tell me in which version the behavior is different?
|
|
Fri Jul 22, 2011 12:55 pm |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
No, sorry, my mistake. I reinstalled 5.1.40 and it isn't working either, it places the commas at the end of the lines or produces the
 |
 |
@p1 INT
,
@p2 NUMERIC
,
@p3 INT
|
result.
I must have confused it with functions. Having brackets around parameters the code is formatted properly. I added them to the rule and now it does not format procedure parameters that lack brackets. The good news is it does not break the code either. I'm considering "whipping" my colleagues to start using the correct syntax. I like that better anyway.
|
|
Fri Jul 22, 2011 1:28 pm |
|
 |
|
|
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
|
|
|