XUL: Printing value from SQL query without using value attribute - sql

I want to print the results of an SQL query in XUL with word-wrapping using the description tag. I have the following code:
<grid>
<columns>
<column flex="2" />
<column flex="1" />
</columns>
<rows datasources="chrome://glossary/content/db/development.sqlite3" ref="?" querytype="storage" >
<template>
<query>select distinct * from Terms</query>
<action>
<row uri="?">
<description value="?name" />
<description value="?desc" />
</row>
</action>
</template>
</rows>
This works for printing the data, but since I'm using the value attribute of description, there's no word-wrapping. I don't understand entirely what I'm doing with the value attribute, but I don't seem to be able to get the values of my SQL query in any other way. So, how could I get those values without the value tag?
Thanks.

So, if anyone's ever looking, I found this out on IRC:
You can use a textnode element to do this.
<description><textnode value="?name" /></description>
This will give you line-wrapping.

Related

Liquibase- Creating index with descending ordering in column issue

I am Facing Error :
attribute 'descending' is not allowed to appear in element 'column'
While running liquidate (3.5) script for creating index :
please find below code :
<createIndex unique="true" indexName="EMPIDX" tableName="Employee">
<Column name="JoiningDate" descending="true" />
<Column name="Empnumber" />
</createIndex>
also I tried :
<Column name="JoiningDate DESC" />
but this give me error : column does not exist :(
I was able to run this code after making a small fix: change Column to column (change from upper case C to lower case c):
<createIndex unique="true" indexName="EMPIDX" tableName="Employee">
<column name="JoiningDate" descending="true" />
<column name="Empnumber" />
</createIndex>

Extracting Text Values from XML in SQL

I'm working with SQL data hosted by a 3rd party, and am trying to pull some specific information for reporting. However, some of what I need to parse out is in XML format, and I'm getting stuck. I'm looking for the syntax to pull the text= values only from the XML code.
I believe the code should something like this, but most of the examples I can find online involve simpler XML hierarchy's than what I'm dealing with.
<[columnnameXML].value('(/RelatedValueListBO/Items/RelatedValueListBOItem/text())[1]','varchar(max)')>
Fails to pull any results. I've tried declaring the spacenames as well, but again...I only ever end up with NULL values pulled.
Example XML I'm dealing with:
<RelatedValueListBO xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://tempuri.org/RelatedValueListBOSchema.xsd">
<Items>
<RelatedValueListBOItem groupKey="Response1" text="Response1" selected="true" />
<RelatedValueListBOItem groupKey="Response2" text="Response2" selected="true" />
<RelatedValueListBOItem groupKey="Response3" text="Response3" selected="true" />
</Items>
</RelatedValueListBO>
Ideally I'd like to pull response1; response2; response3 into a single column. Allowing for the fact that multiple responses may exist. I believe I'm getting stuck with the basic code I've been trying due to the namespaces associated to RelatedValueListBO and the fact that what I want is grouped in groupKey, text, and selected, instead of the value I want just being under the Items node.
You have the namespaces defined in your XML, so you need to define them in the XQuery too.
Fast and dirty method is to replace all namespaces with a "*":
SELECT #x.value('(/*:RelatedValueListBO/*:Items/*:RelatedValueListBOItem/#text)[1]','varchar(max)')
To get all responses in a single column you can use:
SELECT
Item.Col.value('./#text','varchar(max)') X
FROM #x.nodes('/*:RelatedValueListBO/*:Items/*:RelatedValueListBOItem') AS Item(Col)
If you need a better performance, you may need to define namespaces properly.
You can use something like this to extract the value of "text" in the first node of RelatedValueListBOItem
SELECT extractvalue(value(rs), '//RelatedValueListBOItem[1]/#text')
FROM TABLE (xmlsequence(extract(sys.xmltype('<RelatedValueListBO>
<Items>
<RelatedValueListBOItem groupKey="Response1" text="Response1"
selected="true" />
<RelatedValueListBOItem groupKey="Response2" text="Response2"
selected="true" />
<RelatedValueListBOItem groupKey="Response3" text="Response3"
selected="true" />
</Items>
</RelatedValueListBO>'),'/RelatedValueListBO/Items'))) rs;

Why is Silverpop not accepting my XML API call?

I’m working on running a few tests on the Silverpop API, toward an eventual goal of uploading CSVs each evening to update a Silverpop table. I was able to successfully upload csv and xml files and get an oauth access token for the API. However, I’m having trouble with my first actual call.
Here is what I am attempting to send:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Envelope>
<Body>
<ImportList>
<MAP_FILE>silverPopTest.xml</MAP_FILE>
<SOURCE_FILE>silverPopTest.csv</SOURCE_FILE>
<EMAIL>Nicholas#xxxxxxxxxxxxxxxxxxxx.com</EMAIL>
</ImportList>
</Body>
</Envelope>
And here is the 'fault string’ that I am receiving back:
Missing 'xml'parameter
I’m not sure what that means.
I believe I am including all of the required parameters for this command per the docs. I have tried both with and without the “xml” line, as application/xml and text/xml, and a variety of other variations. For reference, here is the code for my entire call:
<cfhttp method="POST" url="https://api3.ibmmarketingcloud.com/XMLAPI">
<cfhttpparam type="header" name="Content-Type" value="application/xml" />
<cfhttpparam type="header" name="Accept" value="application/xml">
<cfhttpparam type="header" name="Authorization" value="Bearer #accessToken#" />
<cfhttpparam type="body" value="#xmlBody#">
</cfhttp>
This is the error xml:
<Envelope><Body><RESULT><SUCCESS>false</SUCCESS></RESULT><Fault><Request/><FaultCode/><FaultString>Missing 'xml'parameter</FaultString><detail><error><errorid>52</errorid><module/><class>SP.API</class><method/></error></detail></Fault></Body></Envelope>
This is my CSV file:
"userid","Email","firstName","lastName"
"123fdasTEST1asdf321","nicholas+test1#xxxxxxxxxxxxxxxxxxx.com","testFirst 1","testLast 1"
"123fdasTEST2asdf321","nicholas+test2#xxxxxxxxxxxxxxxxxxx.com","testFirst 2","testLast 2"
This is my 'map' file:
<LIST_IMPORT>
<LIST_INFO>
<ACTION>ADD_AND_UPDATE</ACTION>
<LIST_ID>9999999</LIST_ID>
<FILE_TYPE>0</FILE_TYPE>
<HASHEADERS>true</HASHEADERS>
</LIST_INFO>
<COLUMNS>
<COLUMN>
<NAME>userid</NAME>
<TYPE>0</TYPE>
<IS_REQUIRED>true</IS_REQUIRED>
<KEY_COLUMN>true</KEY_COLUMN>
</COLUMN>
<COLUMN>
<NAME>Email</NAME>
<TYPE>9</TYPE>
<IS_REQUIRED>true</IS_REQUIRED>
</COLUMN>
<COLUMN>
<NAME>firstName</NAME>
<TYPE>0</TYPE>
<IS_REQUIRED>true</IS_REQUIRED>
</COLUMN>
<COLUMN>
<NAME>lastName</NAME>
<TYPE>0</TYPE>
<IS_REQUIRED>true</IS_REQUIRED>
</COLUMN>
</COLUMNS>
<MAPPING>
<COLUMN>
<INDEX>1</INDEX>
<NAME>userid</NAME>
<INCLUDE>true</INCLUDE>
</COLUMN>
<COLUMN>
<INDEX>2</INDEX>
<NAME>EMAIL</NAME>
<INCLUDE>true</INCLUDE>
</COLUMN>
<COLUMN>
<INDEX>3</INDEX>
<NAME>firstName</NAME>
<INCLUDE>true</INCLUDE>
</COLUMN>
<COLUMN>
<INDEX>4</INDEX>
<NAME>lastName</NAME>
<INCLUDE>true</INCLUDE>
</COLUMN>
</MAPPING>
</LIST_IMPORT>
After working with Silverpop customer support, who said my files and call were working just fine for them, we determined the problem. The XML declaration:
<?xml version="1.0" encoding="ISO-8859-1"?>
Needs to be the first thing in the document. Although it appears that it is above, there are actually several tab stops before it. While Silverpop's tools were trimming those extraneous characters out, ColdFusion was send it exactly as it was, and Silverpop's server just returned a generic error.
The solution was to remove those tab stops, or trim the xml right before sending.

case statement inside of fetchxml script

Please note that although this question is an entirely different question, it relates directly to this question.
The following is the script that returns the dataset for my SSRS chart:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" aggregate="true">
<entity name="account">
<attribute name="bio_employeesworldwide" alias="TotalWorldWideEmployees" aggregate="sum" />
<filter>
<condition attribute="customertypecode" operator="eq" value="2" />
</filter>
<link-entity name="contact" from="parentcustomerid" to="accountid" alias="contact">
<attribute name="bio_webuseraccountstatus" alias="count_bio_webuseraccountstatus" aggregate="countcolumn" />
<attribute name="bio_webuseraccountstatus" alias="bio_webuseraccountstatusgroupby" groupby="true" />
</link-entity>
</entity>
</fetch>
The values for bio_webuseraccountstatus can be Active, Inactive, Disabled, Pending, etc..
In FetchXML is there a way to do a case statement where you "InActive" for every value that is not equal to "Active" ?
As you can see I've been trying to solve this issue within the reporting layer, but am experiencing lots of "string format" issues.
Can this be done with the dataset layer (fetchxml) instead?
According to this Microsoft forum post:
There's no equivalent function in FetchXml. Instead, you will need to return each field value, and process the CASE logic in the calling code. If this FetchXml is to be used in a report, then you may be able to implement the CASE logic in a calculated field on the report.
You can always parse the output of the fetchxml on return.
So rather than pushing to the screen, report, or db, the original record field of isreceivetravelalerts, you check the status (zero or one) and rewrite it, and add the new variable to your output. Clunky, but useful.
if ($record->isreceivetravelalerts == 1)
{
$travel_alerts = "Active";
}
$travel_alerts = "Inactive";

Converting SQL Query to XML Query for SharePoint List

I'm using SQL Reporting 3.0 and I'm trying to query a SharePoint list. Since the SharePoint list can only be in XML inside of SQL reporting, I'm trying to figure out to to convert my SQL query into an XML query. The area I'm stuck at is inside of WHERE. I'm having difficulty with IN(#). Is there a way to convert this into an XML query? Thank you for your help its greatly appreciated.
SQL Query
SELECT Hours, Date, Project, ID, Created_By,Month
FROM TimeTracking
WHERE Project IN(#Project) AND Month IN(#Month)
XML Query
<RSSharePointList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ListName>Time Tracking</ListName>
<ViewFields>
<FieldRef Name="Hours" />
<FieldRef Name="Date" />
<FieldRef Name="Project" />
<FieldRef Name="ID" />
<FieldRef Name="Created_By" />
<FieldRef Name="Month" />
</ViewFields>
<Query>
<Where>
?
</Where>
</Query>
</RSSharePointList>
Here's an example on MSDN on using FOR XML PATH to return your query as XML. You can also add a root element by using ROOT.
Please refer to te following article:
http://msdn.microsoft.com/en-us/library/bb510462.aspx