SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Generating DECLARE statement

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
Generating DECLARE statement
Author Message
salmarko



Joined: 04 Apr 2012
Posts: 1
Country: Serbia

Post Generating DECLARE statement Reply with quote
Hi. Is there a way to insert DECLARE keyword based on selected parametar in query. Example:

SELECT OrderId
FROM Orders
WHERE CustomerId = @CustomerId

I would like to select @CustomerId param, and then to press some global key combination, and assistent should insert "DECLARE @CustomerId INT" above this query. Is there a way to do this? If not, maybe it would be a good feature?
Wed Apr 04, 2012 3:55 am View user's profile Send private message Send e-mail
gemisigo



Joined: 11 Mar 2010
Posts: 2109

Post Reply with quote
A similar (yet not exactly identical) effect could be achieved using snippets, regular expressions and selecting the whole query. You'd have to select all of it because you cannot retrieve the type of the variable otherwise. But by selecting everything you cannot decide which variable to declare so it would declare them all.

Adding variables to the script before declaring them and then going back to declare them when developing a code is a bit awkward (though I must admit it happens) and designing database doing this regularly is somewhat... clumsy... It shows the lack of forethought.

A snippet that could do this would be extremely complex. For example, to avoid re-declaration of already declared variables, the whole contents of the editor should be selected and parsed for a rather large number of different cases. Creating and using this snippet would be cumbersome to the extent I consider "not worth the effort by far".

I can imagine it as some kind of refactoring function, though. These appear to have more control over the contents of the editor. But they are an unknown area for me. While the existing refactoring queries can be modifed I doubt there are user defined refactorings. Now those would be a mean feature to add :)
Wed Apr 04, 2012 4:57 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.