Replies

Okay, so if I'm understanding you correctly, even if the user field changes after the initial insertion of the object, the userid field should stay the same?

I'm guessing you're looking for the %%ID special reference.  Something like this:

Class Testing.TestingCalcProps Extends %Persistent
{

Property user As %String;

Property a As %String [ Calculated, SqlComputeCode = {set {*} = {user}_{%%ID}}, SqlComputed];

}

I'd recommend the Calculated keyword, as elements only gain id's after they're saved, which could perhaps lead to inaccurate values in the calculated property before the saving happens.

Here's the resource which talks about these properties: https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY...

And here's the one that mentions %%ID: https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY...

This is probably a simple syntax error.  Let's see the code you're using, from start to finish, setting up, preparing, then executing the query.  Perhaps the syntax is wrong on the preparation step.

The post build script executes on the node that the Jenkins build ran on.  Therefore, that node machine is “local” for the purposes of copying remote files, and the machine where the XML file you want to copy lives is the “remote” machine.

You’ve probably seen this, but here’s the documentation for the Secure Copy Protocol (scp) command:

https://linuxize.com/post/how-to-use-scp-command-to-securely-transfer-files/

The relevant form for you should be:

scp user@hostOfFileToCopy:/path/to/fileToCopy /path/to/newCopy

“user” needs to be the name of a user who has permissions to copy the file. hostOfFileToCopy identifies the machine on which that XML file lives (could be an IP address). /path/to/fileToCopy is the absolute path, on that machine, of the file you want to copy.

/path/to/newCopy is the absolute path for the destination of the copy on the machine the Jenkins build is running on, not just the relative path from within the Jenkins workspace.  For example, while your path within the Jenkins workspace might be “/ReportFiles/Results.xml", the absolute path on the machine is probably something like “/Jenkins/workspace/ReportFiles/Results.xml”

Hope this helps.

If you're curious, this is why what you tried originally got you unexpected results.

You passed the embedded sql statement an array with a missing subscript,  :IDArray(), hoping it would put your first result in IDArray(1), your second in IDArray(2), etc.  The problem with that is that a single embedded sql statement like the one you used will only ever return one result row: the first row that matches the criteria.  So what you were likely seeing is your first valid ID stored in IDArray(1), and none of the other ones you wanted present.

So why can it accept an array as an output argument at all, then?  When embedded sql sees an array as an output argument, it gives that array a subscript for each of the columns in the result row.  So IDArray(1) wasn't the first ID, but rather the first column of the returned sql row.  For example, &sql(select id, name, age into :result() from Person) would return the id into result(1), name into result(2), and age into result(3).

Hope this helps.  Good luck!

This is great, thanks.  Just implemented it.  Worked like a charm.

Also let me just confirm (and this wasn't needed in my particular implementation): if I call giveMeAFalseMe from Cache when it's returning "true" or "false", Cache will translate "true" into a truthy %Boolean return value, right?

It appears that, for whatever reason, the System files are not automatically included for every class you write in Cache 2010.  When a class inherits from %RegisteredObject, you don't need to worry, because they'll be included via inheritance.  For other classes, like the one where I was seeing this issue, the system files are unavailable unless included by hand.

Adding Include.%occStatus to the top of the non-compiling classes fixes the issue for the $$$OK macro, although a better practice is to use Include.%occInclude, to get some other standard stuff with the status routines.

Here the simplest one I have that had the issue if you want too look at it.  Note my answer on what I've discovered (which was enough to solve the issue).

<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Class name="CACHE2010.Build">
<TimeCreated>64952,32335.711823</TimeCreated>

<Parameter name="SrcVer">
<Description>
Location and Revision of this file in Perforce (Auto-updating)</Description>
<Default>$Id: //custom_ccrs/_common/tools/CCRToolsBuild/BuildManifests/Cache2010/Build.xml#1 $</Default>
</Parameter>

<XData name="BuildManifest">
<Description>
This is a build manifest. Here we describe build steps in XML format.</Description>
<Data><![CDATA[
<Manifest>

<!-- Change into namespace -->
<Namespace Name="CCRClientTools" Ensemble="0" Code="CCRTOOLS-CODE" Data="CCRTOOLS">
<Configuration>
<!-- Have  database for code -->
<Database Name="CCRTOOLS-CODE" Dir="c:\intersystems\cache\mgr\ccrtools-code\" Create="overwrite" InitialSize="200" ExpansionSize="60" />
</Configuration>

</Namespace>

</Manifest>
]]></Data>
</XData>

<Method name="Build">
<Description>
This method is called to pass parameters into generated build method</Description>
<ClassMethod>1</ClassMethod>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
     Set pLogLevel=3
     Set sc=..RunBuildManifest(.vars, .pLogLevel)

     Quit sc
]]></Implementation>
</Method>

<Method name="RunBuildManifest">
<Description>
This is a standard %Installer method generator whose code is generated by XGL.</Description>
<Internal>1</Internal>
<ClassMethod>1</ClassMethod>
<CodeMode>objectgenerator</CodeMode>
<FormalSpec><![CDATA[&pVars,pLogLevel:%Integer,pInstaller:%Installer.Installer]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
     #; Let our XGL document generate code for this method.
     quit ##class(%Installer.Manifest).%Generate(%compiledclass, %code, "BuildManifest")
]]></Implementation>
</Method>
</Class>
</Export>