There's two ways around this:

  1. If this is something you're running one off in, say, the sql query tool within the management portal, then you will want to repeat the single quote to be "Select * from cnd.Facilities  where name like ''%Grill''s BBQ%'" and this will escape the single quote.
  2. If this is a query being called within your code and the value could be anything passed to it, then you will want to look to use parameterised SQL queries. An example can be found for SQL adapters here.

Hey Scott.

I'm not sure if this will work at all, but have you tried extending your timeout for your CSP gateway?

Management Portal -> System Administration -> Configuration -> Web Gateway Management is the route to this. The username you'll then need is "CSPSystem" and the password should be the default password used when installing the system.

From within here you can navigate to "Default Parameters" and increase the Server Response Timeout parameter.

I have to admit, I'm not familiar with where that code has come from, so it's difficult to comment on the syntax.

That said, I think I can confidently say that your first line has the OBXgrp hard coded to the first repetition, but the second line has it set to k2. You will want a for each for the OBXgrp and a seperate one for the NTEs within the OBXgrp.

Hey Ciaran.

To overcome the issue of multiple ORCs overwriting your PIDgrp NTE in your copy, you will likely need to maintain a separate count of what is being copied over.

So you could look to do something similar to: (pay specific attention to actions 2, 9, and 10) 

Which would then give the following result:

You could then take it a step further by setting the value of your PIDgrp NTE to your count value before incrementing it:

Which would then give you:

As a warning, I did find that the DTL building went a bit weird when it comes to the auto-applying of the key counts. So I was adding a For Each on a repeating field and it assigned a key of say k1, then when adding the sets within the for each loop, it would randomly use k2 or k3 in the field. it might just be a limitation of how I was building things up, but it's one to keep an eye out for as it'll give you unexpected results if it happens to you. Good luck :)

Hey Ephraim.

I have thrown together a task which should do what you need. The code is a bit verbose and could be cut down a touch, but hopefully it's human readable enough for you to pick out what its doing.

Effectively, it takes the current date to then grab a date from last month, and then gets the first and last date of that month to then use in the audit method.

Class Demo.Tasks.MonthlyAudit Extends %SYS.Task.Definition

Method OnTask() As %Status
    Set tSC = $$$OK

    //Get Current Date
    Set CurentDatetime = $ZDATETIME($HOROLOG,3)

    //The report needs to be for last month, so get a date from last month based on todays date
    Set LastMonth = $SYSTEM.SQL.DATEADD("MM",-1,CurentDatetime)

    //Get last Day of last month As Horolog
    Set LastDayHoro =  $SYSTEM.SQL.LASTDAY(LastMonth)

    //Convert Horolog into a Date
    Set LastMonthEnd = $ZDATETIME(LastDayHoro,3)

    //Get First Day of Last Month
    Set LastMonthStart = $SYSTEM.SQL.DATEPART("YYYY",LastMonthEnd)_"-"_$SYSTEM.SQL.DATEPART("MM",LastMonthEnd)_"-01"

    //Switch to the %SYS Namespace
    ZNspace "%SYS"

    Set tSC = ##class(%SYS.Audit).Export("AuditExport.xml",,,LastMonthStart_" 00:00:00",LastMonthEnd_" 23:59:59")

    Quit tSC


Then, when setting the task up, I would set it to run on the first Monday of the Month, and it will grab everything from the previous month.