SSMS Snippets and Shortcuts - sql-server

I'm using SSMS 2014. I am able to insert a snippet but they don't seem to respond to shortcuts (ie crproc[tab])
Is this feature known to work?
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>prod1</Title>
<Description>testing</Description>
<Author> dale </Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Shortcut>crproc</Shortcut>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>DatabaseName</ID>
<ToolTip>Name of database.</ToolTip>
<Default>DB</Default>
</Literal>
</Declarations>
<Code Language="SQL">
<![CDATA[
------------------------------------------------------
-- FILENAME: Template-Expansion.snippet
-- PURPOSE: Template for Expansion (Insert) snippets.
-- AUTHOR: Ken O. Bonn
-- DATE: May 15, 2013
------------------------------------------------------
SET NOCOUNT ON;
EXEC SP_HELPDB $DatabaseName$;
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>

No, for some reason Microsoft seem to have no interest in actually implementing this feature, despite code snippets being totally useless without it (because of the number of mouse clicks and key presses you need to insert a snippet).
How many times a day do you type "SELECT * FROM..." or "SELECT TOP 10 * FROM "... etc..??!
Very frustrating!
Even SSMS 2016 Release Candidate still does not support it.
"ApexSQL Complete" (a free tool) apparently will do it, but this does not support SSMS 2016 yet!

Add your snippet to the "Functions" folder where other SurroundsWith snippets are found. Then press press CTRL + K, CTRL + S (shortcut for SurroundsWith Snippets) and type a few letters from your snippet name and press enter. If only the "Functions" folder has SurroundsWith snippets then no other folders will show in the context menu. Otherwise you can type a few letters from the appropriate folder name and press tab. This process is much like this answer.
For my environment the Begin, If and While snippets are located:
C:\Program Files (x86)\Microsoft SQL
Server\130\Tools\Binn\ManagementStudio\SQL\Snippets\1033\Function
Here is an example snippet for SELECT * FROM:
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Select</Title>
<Shortcut>sel</Shortcut>
<Description>SELECT * FROM _ WHERE 1=1 AND</Description>
<Author/>
<SnippetTypes>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="SQL">
<![CDATA[
SELECT * FROM dbo.$selected$$end$
WHERE 1=1
--AND
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>

In ApexSQL Complete you have possibility to do this and of course that support SSMS 2016 and even new SSMS 17 RC, except that it is totally free

Don't worry about giving it a specific shortcut.
Just add it under the my snippets folder.
Make sure to save as .snippet
Hit ctrl+K, Ctrl+S
down arrow to my snippets enter
down arrow to the snippet you want enter
your snippet will surround the code you wanted it to.

Related

WiX installer can't open config file

I have a WPF application and I've created an MSI to install it with the WixToolset 3.11 and Visual Studio Extension 2019. I'm trying to add either XmlFile or XmlConfig item to change values in the config file. I'm getting the following error:
Failed to open XML file C:\Program Files(x86)\CO Apps\Main App\OurApp.exe.config. system error: -2147024786
The file path is the full filepath because I gave it the full path trying to resolve the issue. Here's the important parts of the wxs file
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:wixutil="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="9E76F000-5525-4BDF-8262-AE46B035D9CE"
Name="Our App"
Language="1033"
Version="2.0.0.0"
Manufacturer="CO Apps"
UpgradeCode="7CFB1B51-F5D5-4AD4-A509-F5C9BC05F875">
<Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="Our production application." />
<Directory Id="ProgramFilesFolder">
<Directory Id="VTAPPSDIR" Name="CO Apps">
<Directory Id="INSTALLFOLDER" Name="Our App">
<Component Id="MainExecutable" Guid="748368D7-7581-4809-A8FE-DFB1093D6A02">
<File Id="MainFile" Name="$(var.OurApp.TargetFileName)" DiskId="1" Source="$(var.OurApp.TargetDir)OurApp.exe" KeyPath="yes"></File>
<File Id="OurApp.exe.config" ReadOnly="no" Source="$(var.OurApp.TargetDir)OurApp.exe.config"></File>
... More File items for DLLs
<wixutil:XmlFile Id="SetAppMode" Action="setValue" File="C:\Program Files (x86)\CO Apps\Our App\OurApp.exe.confg" ElementPath="configuration/userSettings/OurApp.Properties.Settings/setting/AppMode/value" Value="Main" />
</Directory>
</Directory>
</Directory>
So I'm trying to set the "AppMode" value to "Main" when this installs. What I'm trying to set isn't the point it's that it can't seem to find or open the file. I've tried putting the XmlFile in its own component. I've tried several variations of File paths including [INSTALLDIR] and [INSTALLLOCATION] and the filename by itself. Without that line everything works great. With that line in, I get the error and it rolls back the install. I also tried XmlConfig instead of XmlFile:
<wixutil:XmlConfig Id="ClearConfigAppMode" Action="delete" File="[INSTALLLOCATION]OurApp.exe.config" ElementPath="userSettings/OurApp.Properties.Settings" Name="AppMode" />
<wixutil:XmlConfig Id="SetAppMode" Action="create" File="[INSTALLLOCATION]OurApp.exe.config" ElementPath="userSettings/OurApp.Properties.Settings" On="install" Node="element">
<wixutil:XmlConfig Id="SetConfigAppModeName" ElementId="SetAppMode" File="[INSTALLLOCATION]OurApp.exe.config" Name="name" Value="AppMode" />
<wixutil:XmlConfig Id="SetConfigAppModeSerializeAs" ElementId="SetAppMode" File="[INSTALLLOCATION]OurApp.exe.config" Name="serializeAs" Value="String" />
</wixutil:XmlConfig>
<wixutil:XmlConfig Id="SetAppModeValue" Action="create" File="[INSTALLLOCATION]OurApp.exe.config" ElementPath="userSettings/OurApp.Properties.Settings" On="install" Node="element" Sequence="2">
<wixutil:XmlConfig Id="SetAppModeVAlueMain" ElementId="SetAppModeValue" File="[INSTALLLOCATION]OurApp.exe.config" Name="Value" Value="Main" />
</wixutil:XmlConfig>
Since XmlConfig doesn't have setValue on an existing element I used the delete action to remove the item for use in development and insert a new one. Same error. It happens logged on as myself or as Administrator. Does anyone have a working example of WiX with WPF creating a MSI? I'm not looking for something as complex as WixBA. I just need to modify the app.exe.config file on install.
Thanks,
Mike
Example: Though I rarely use this feature, I have this working example here (my test project for XML): https://github.com/glytzhkof/WiXUpdateXmlFile. Snippets of the sample here and here.
Disclaimer: I am not sure if follows best practice for XML updates, since I prefer to do XML updates from application launch code instead - if possible (single source, easier debugability and in general more familiar territory for most developers).
app.config/web.config appsettings: Maybe check out this answer regarding appsettings or this answer (looks better) - just for your review, not necessarily a suggestion. Keeping deployed files read-only helps a lot to overwrite them reliably during updates and the file you generate can be kept untouched by the installer (the file is de-coupled from installer - it never touches them). Or as I wrote: HKCU can also be used to write "the few settings you actually have to change". Not so nice conceptually?
Clouded Settings: Personally I think settings should never be file-based but clouded in our day and age (kept in a remote database). See section 6 and 7 here. How realistic this is for your application I don't know. New challenges and problems - no doubt (network issues, firewalls, launch problems, etc...), but benefits: versioned settings, recovery and management (enforce new settings). Not sure about all the practicalities - never been involved that much, but would love to get rid of settings files - especially for corporate apps. However, sometimes nice concepts don't meet reality well - maybe it is too involved?

Difficulty using XMLView in codenameone

I am trying to use XMLView to display small html. This is the html
<?xml version="1.0" encoding="windows-1252"?>
<doc><body><p uiid="headline"> Election Result</b></p><p>Ward -- W1001<br>
</p><p>Votes For -- ABP,200<br> -- A,100<br></p><carousel> <img src="http://res.cloudinary.com/okwui/image/upload/v1545561341/pukuxkn2pgmgbcplqgi8.png"/><br>
<img src="http://res.cloudinary.com/okwui/image/upload/v1545561342/zkwfawmolbvta3lfd2ld.png"/><br></carousel><p>
Additional Notes -- <br></p><p>Election -- Presidential2019<br></p><p>Date of Election -- Sun Dec 23 11:35:14 WAT 2018<br></p><p>Booth -- B001<br></p>
<p>Constituency -- C001<br></p><p>State -- Abia<br></p> </body></doc
I keep getting this error
java.lang.NullPointerException
at com.codename1.xml.Element.iterator(Element.java:767)
at com.codename1.components.xmlview.ParagraphView.getText(ParagraphView.java:66)
at com.codename1.components.xmlview.ParagraphView.getText(ParagraphView.java:68)
at com.codename1.components.xmlview.ParagraphView.getText(ParagraphView.java:68)
at com.codename1.components.xmlview.ParagraphView.getText(ParagraphView.java:68)
at com.codename1.components.xmlview.ParagraphView.getText(ParagraphView.java:68)
at com.codename1.components.xmlview.ParagraphView.getText(ParagraphView.java:68)
at com.codename1.components.xmlview.ParagraphView.getText(ParagraphView.java:75)
at com.codename1.components.xmlview.ParagraphView.createView(ParagraphView.java:50)
at com.codename1.components.xmlview.XMLView.createView(XMLView.java:377)
at com.codename1.components.xmlview.XMLView.setXML(XMLView.java:356)
at com.codename1.components.xmlview.XMLView.setXML(XMLView.java:302)
Obviously there is something wrong with the XML file but I am unable to pinpoint. Pls help.
You need to follow the syntax mentioned in the XMLView project e.g. <br> isn't valid XML. I'm not sure if body is necessary or not:
See https://github.com/shannah/cn1-xmlview/blob/master/src/SampleNewsFeed.xml

Error in Jdeveloper 12.2.1.2 while upgrading application from jdeveloper 11.1.1,7,1

I was trying to upgrade my application from 11g to 12c. In that i am getting an error.
<org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl> <ViewHandlerImpl> <_isTimestampCheckEnabled> <Apache Trinidad is running with time-stamp checking enabled. This should not be used in a production environment. See the org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION property in WEB-INF/web.xml>
<org.apache.myfaces.trinidadinternal.util.FrameBustingUtils> <FrameBustingUtils> <_getFrameBustingString> <The framebusting context param 'oracle.adf.view.rich.security.FRAME_BUSTING' has been deprecated. Please change your web.xml to use 'org.apache.myfaces.trinidad.security.FRAME_BUSTING' instead. The legal values are 'always', 'never', and 'differentOrigin'. If you were setting the value of 'oracle.adf.view.rich.security.FRAME_BUSTING' to 'differentDomain', then please note that you should set 'org.apache.myfaces.trinidad.security.FRAME_BUSTING' to 'differentOrigin'.>
<oracle.adf.view> <UIXRegion> <_logNullValueMessage> <The expression "#{bindings.AddTypeBTF1.regionModel}" that was specified for the RegionModel "value" attribute of the region component with id ":pt1:r1" evaluated to null. Using an empty RegionModel instead.>
<oracle.adf.view> <UIXRegion> <_logNullValueMessage> <The expression "#{bindings.AddTypeBTF1}" evaluated to "".
The expression "#{bindings}" evaluated to "".
>
<org.apache.myfaces.trinidadinternal.style.xml.parse.StyleSheetDocument> <StyleSheetDocument> <_resolveStyleNode> <Circular dependency detected in style af|dvt-timeline>
<Sep 19, 2017, 12:48:00,384 PM IST> <Warning> <Socket> <BEA-000449> <Closing the socket, as no data read from it on 127.0.0.1:50,050 during the configured idle timeout of 5 seconds.>
This is my page
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document id="d1" title="PMS">
<af:form id="f1">
<af:pageTemplate viewId="/PMS/Template/PMSTemplate.jspx" id="pt1">
<f:facet name="Content">
<af:region value="#{bindings.AddTypeBTF1.regionModel}" id="r1"/>
</f:facet>
</af:pageTemplate>
</af:form>
</af:document>
</f:view>
</jsp:root>
This is binding of the page
<?xml version="1.0" encoding="UTF-8" ?>
<pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel"
version="11.1.1.65.57" id="PMSTypeMasterPageDef"
Package="PMS.Pages">
<parameters/>
<executables>
<variableIterator id="variables"/>
<taskFlow id="AddTypeBTF1"
taskFlowId="/PMS/TaskFlows/AddTypeBTF.xml#AddTypeBTF"
activation="deferred"
xmlns="http://xmlns.oracle.com/adf/controller/binding"/>
</executables>
<bindings/>
</pageDefinition>
There is no warning in the page or else in the pagedef.
i tried to clean my application as well as removed all cache and useless stuff from my PC. Still it's not working.
I asked my colleague about this issue. they have faces the similar one. and it was solved by cleaning the application and they have restarted the Jdeveloper.
But same is not working with me.
I searched on the internet. many sites suggest that there might be no entry in the pagedef. but i can find entry of taskflow there as well.
<context-param>
<description>If this parameter is true, there will be an automatic check of the modification date of your JSPs, and saved state will be discarded when JSP's change. It will also automatically check if your skinning css files have changed without you having to restart the server. This makes development easier, but adds overhead. For this reason this parameter should be set to false when your application is deployed.</description>
<param-name>org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION</param-name>
<param-value>false</param-value>

Posting hazardous materials information to Amazon MWS

We are using MWS service to create/update items on Amazon marketplace. Everything is working fine except we are not able to send hazardous item info for an item through XML.
Which XML fields should we use for hazardous materials information?
Example Feed:
<?xml version="1.0" ?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema
-
instance" xsi:noNamespaceSchemaLocation="amzn
-
envelop
e.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>M_SELLER_354577</MerchantIdentifier>
</Header>
<MessageType>Product</MessageType>
<PurgeAndReplace>true</PurgeAndReplace>
<Message>
<MessageID>1</MessageID>
<Op
erationType>Update</OperationType>
<Product>
<SKU>1Z
-
500ABR
-
FLAT</SKU>
<ProductTaxCode>A_GEN_TAX</ProductTaxCode>
<LaunchDate>2005
-
07
-
26T00:00:01</LaunchDate>
<DescriptionData>
<Title>Lyric 500 tc Queen Flat Sheet, Ivory</Title>
<Brand>Peaco
ck Alley</Brand>
<Description>Lyric sheeting by Peacock Alley is the epitome of simple and classic</Description>
<BulletPoint>made in Italy</BulletPoint>
<BulletPoint>500 thr
ead count</BulletPoint>
<BulletPoint>plain weave (percale)</BulletPoint>
<BulletPoint>100% Egyptian cotton</BulletPoint>
<Manufacturer>Peacock Alley</Manufacturer>
<SearchTerms>bedding</SearchTerms>
<SearchTerms>Sheets</SearchTerms>
<Item
Type>flat
-
sheets</ItemType>
<IsGiftWrapAvailable>false</IsGiftWrapAvailable>
<IsGiftMessageAvailable>false</IsGiftMessageAvailable>
<RecommendedBrowseNode>60583031</RecommendedBrowseNode>
<RecommendedBrowseNode>60576021<
/RecommendedBrowseNode>
</DescriptionData>
<ProductData>
<Home>
<Parentage>variation
-
parent</Parentage>
<VariationData>
<VariationTheme>Size
-
Color</VariationTheme>
</VariationData>
<Material>cotton</Material>
<
ThreadCount>500</ThreadCount>
</Home>
</ProductData>
</Product>
</Message>
<Message>
</AmazonEnvelope>
There are a few fields in the XSD that deal with hazardous materials
There is the <EUcompliance> tag, but according to the XSD, that could only be used instead of <Home> which does not make any sense to me. For details look at Products.xsd and EUcompliance.xsd
There are <HazmatItem>s in <FBA> and <ToysBaby> but they share the same fate as the above. For details look at amzn-base.xsd for its definition and FBA.xsd and ToysBaby for its use.
I have no clue why neither is valid alongside other product types, but hey, that's what their XSDs say, and it's not the first time I'm puzzled what the schema designers at Amazon were thinking... so you're left with
Put it in <OtherItemAttributes> which is valid for all product types. It would go between </ItemType> and <IsGiftWrapAvailable>. For details look at products.xsd
I don't know why you'd want to include hazmat information in the feed, but that's where I'd put it.
(BTW, you have an extra tag at the end which shouldn't be there)

how to insert html tag inside sql in Liquibase migration?

I need to update my data that have html tag inside so wrote this on liquibase
<sql> update table_something set table_content = " something <br/> in the next line " </sql>
it apparently doesn't work on liquibase ( i got loooong errors .. and meaningless). I tried to remove <br/> and it works.
my question is, is it possible to insert / update something that contains xml tag in Liquibase ?
I am using liquibase 1.9.3 with Grails 1.1.1
edited: forgot to set code sample tag in my examples.
As the liquibase author mentions here you'll need to add CDATA section inside <sql>.
In your particular example that would become:
<sql><![CDATA[ update table_something set table_content = " something <br/> in the next line " ]]></sql>
Even better not to use a <sql> tag at all (I added the where clause ...):
<changeSet author="author" id="table_something_1">
<update tableName="table_something">
<column name="table_content"><![CDATA[ something <br/> in the next line ]]></column>
<where>id=1</where>
</update>
<rollback />
</changeSet>

Resources