Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagexml
titleDelete DataModel Query
linenumberstrue
<Query>
  <DeleteAll>
    <VendorInfo>
      <vendorName eq="Phidget"/>
    </VendorInfo>
  </DeleteAll>
</Query>

 


DataModel with one Complex type

...

DataModel with one Attribute that is of Array defined via Cardinality.


Save Query Results to a CSV

In some cases the user may want to save the query results to a CSV file. This can be achieved easily using 3 step process:

  • Find Data
  • Convert result to comma separated lines
  • Save the content
  • View the content

For example: Let's say you have a DataModel VendorInfo as defined below.

Code Block
languagexml
titleSample project
linenumberstrue
collapsetrue
<Namespace Name="SimpleModel">
  <Domain Name="MyModels">
    <DataModel Name="VendorInfo">
      <Sid name="VendorSysId"/>
      <String name="vName"/>
      <String name="vTitle"/>
      <String name="vLocation"/>
    </DataModel>
  </Domain>
</Namespace>

Generic Macro to Save File:

You can make is as part of your project.

Note the content has to be part of ProcessData.

Code Block
languagexml
titleGeneric SaveFile Macor
linenumberstrue
collapsetrue
<Macro Name="SaveFile">
  <Argument>
    <FilePath/>
  </Argument>
  <Result>
    <JexlScript>
      var file = "[:$Macro.Argument.FilePath:]";
      var data = sffContext.getProcessData(["toCSV","result"]);
      sffLog.info("Data" + data);
      sff:saveTxt("text", file, data);
      return null;
    </JexlScript>
  </Result>
</Macro>
Code Block
languagexml
titleFindConvertAndSave
linenumberstrue
collapsetrue
<Query>
  <Find>
    <VendorInfo>
      <vName ne=""/>
    </VendorInfo>
  </Find>
  <SetProcessData key="toCSV.result" value="Name,Title,Location[:EOL:]"/>
  <For Each="val" In="Find.Result.VendorInfo">
    <SetProcessData key="toCSV.result" Value="[:$ProcessData.toCSV.result:][:$LocalData.val.vName:],[:$LocalData.val.vTitle:],[:$LocalData.val.vLocation:][:EOL:]"/>
  </For>
  <SaveFile>
    <FilePath>
      ./resources/querydata.csv
    </FilePath>
  </SaveFile>
</Query>

Finally to View the file:

Code Block
languagexml
titleView OR Download File
linenumberstrue
collapsetrue
http://<ip>:<port>/fid-tqlengineres/<nameoffile>