size = 49
ClassMethod Solve(o As %String) As %Integer
{
f i=1:1 s c=$p(o,",",i) ret:'$lf($lfs(o),-c) c
}- Log in to post comments
size = 49
ClassMethod Solve(o As %String) As %Integer
{
f i=1:1 s c=$p(o,",",i) ret:'$lf($lfs(o),-c) c
}Given (IRIS 2021.2):
Class fixxer.decars Extends %Persistent [ DdlAllowed, SqlRowIdName = UniqueIdentifier ]
{
Index iUnq On (brand, MaxSpeed, color) [ IdKey, PrimaryKey, Unique ];
Property brand [ SqlColumnNumber = 2 ];
Property MaxSpeed;
Property color;
}USER>d $system.SQL.Shell() SQL Command Line Shell ---------------------------------------------------- The command prefix is currently set to: <>. Enter , 'q' to quit, '?' for help. [SQL]USER>>select * from fixxer.decars 1. select * from fixxer.decars UniqueIdentifier brand MaxSpeed color 0 Rows(s) Affected statement prepare time(s)/globals/cmds/disk: 0.0020s/5/140/0ms execute time(s)/globals/cmds/disk: 0.0004s/1/719/0ms cached query class: %sqlcq.TEST.cls4 --------------------------------------------------------------------------- [SQL]USER>>alter table fixxer.decars alter column color rename color2 2. alter table fixxer.decars alter column color rename color2 0 Rows Affected statement prepare time(s)/globals/cmds/disk: 0.0153s/2 113/13 157/0ms execute time(s)/globals/cmds/disk: 0.1492s/52 206/467 790/0ms cached query class: %sqlcq.TEST.cls5 --------------------------------------------------------------------------- [SQL]USER>>select * from fixxer.decars 3. select * from fixxer.decars UniqueIdentifier brand MaxSpeed COLOR2 0 Rows(s) Affected statement prepare time(s)/globals/cmds/disk: 0.0741s/38 529/179 560/0ms execute time(s)/globals/cmds/disk: 0.0003s/1/719/0ms cached query class: %sqlcq.TEST.cls4 --------------------------------------------------------------------------- [SQL]USER>>
Now:
Class fixxer.decars Extends %Persistent [ DdlAllowed, SqlRowIdName = UniqueIdentifier ]
{
Index iUnq On (brand, MaxSpeed, color) [ IdKey, PrimaryKey, Unique ];
Property brand [ SqlColumnNumber = 2 ];
Property MaxSpeed;
Property color [ SqlFieldName = COLOR2 ];
}PS: by the way Studio highlights the error in the following code
&sql(alter table fixxer.decars alter column color rename color2)But the compilation goes without errors.
Perhaps the method will be useful to you: $SYSTEM.Util.CleanDeadJobs()
See
$$TableName^%occLGUtil(pClass) (taken from sources %DeepSee.Report.Model.Report) ##class(%DeepSee.Utils).%GetSQLTableName(pClass) ##class(%ZEN.DataModelUtils).GetSQLTableName(pClass) ##class(%DeepSee.Generator).%GetSQLTableName(pClass) (my choice)
It is worth remembering that the table name can be a reserved word, so you need to put it in quotation marks.
For example, the method %DeepSee.Generator:%GetSQLTableName does not always work correctly for Caché:
Class count.sum.select Extends %Persistent [ SqlTableName = "current_date.max" ]
{
ClassMethod TableName(which = 0) [ CodeMode = objectgenerator ]
{
set sch=%compiledclass.SqlSchemaName, tab=%compiledclass.SqlTableName
do %code.WriteLine($c(9)_"quit $p("""_sch_"."_tab_","_sch_","_tab_""","","",which+1)")
quit $$$OK
}
/// d ##class(count.sum.select).Test()
ClassMethod Test()
{
f i=0:1:2 w ..TableName(i),!
s pClass=$classname()
w !,##class(%DeepSee.Generator).%GetSQLTableName(pClass),!
w $$TableName^%occLGUtil(pClass),!
w ##class(%DeepSee.Utils).%GetSQLTableName(pClass),!
w ##class(%ZEN.DataModelUtils).GetSQLTableName(pClass),!
}
}
USER>d ##class(count.sum.select).Test()
count_sum.current_date.max
count_sum
current_date.max
count_sum."current_date" ERROR!
count_sum.current_date.max
count_sum.current_date.max
count_sum.current_date.maxIn IRIS 2021.2, an error occurs yet at the compilation stage of the class.
In Caché 2018.1, which the author indicated, there is no such function. In addition, instead of HH need to specify HH24, otherwise instead of 20220126155704 will get 20220126035704.
I would like to avoid string manipulationDelimiters in the format are required, so you will have to manipulate the strings anyway.
$tr($system.SQL.TOCHAR($h,"YYYYMMDD HH24 MI SS")," ","") or $tr($system.SQL.TOCHAR($h,"YYYY^MM^DD^HH24^MI^SS"),"^","")
LOAD DATA (SQL)2021.2
Ok, the index can be omitted.
The table data is stored in different globals: *D - for data, *I - for indexes, *S - for streams. You can get the size of the data parts you want.
Example [Size()]:
select * from %SYS.GlobalQuery_Size('C:\InterSystems\Cache\mgr\samples','','*D,*S',0,0,1) order by "Allocated MB" descSee the sources of method %SYSTEM.SQL:Export() for a description of the parameters.
Only instead of 0, use 1, for example:
SAMPLES>w $$Export^%qarDDLExport("Sample","*","C:\Temp\Sample.sql","WNS",1,0,0,0,0)Will an undocumented command suit you?
Try the following:
That's what I expected to see.
But need remember that
This method is only available for stored properties.In other words, if the storage changes tomorrow, will have to rewrite a bunch of code.
I meant the length of the code.
I can write like this:
<..> select a->b->c->d into :r from table where %ID=:id <..>
Can you give a complete code example for a->b->c->d using GetStored?
And if you need to get a->b->c->d and they at the same time can be null?
Another option
In this case, you should wait for IRIS 2021.2 with built-in Python and use Jinja directly.
In the meantime, there is the following:
There is a ready-made method for this: getFileslink
Usage example:
s path="C:\Temp" s pExtension=1 s pExtension(1)="*" s pTempNode=$i(^CacheTemp) k ^CacheTemp(pTempNode) d ##class(%SQL.Util.Import).getFiles(path,.pExtension,pTempNode,1) m dirlist=^CacheTemp(pTempNode) k ^CacheTemp(pTempNode) zw dirlist
It's okay, I already have a minus.
It looks like this is my last comment here.
UPD:
w $$Iso8601ToTimeStamp("2021-10-22T08:00:00+0900"),!
w $$Iso8601ToTimeStamp("2021-11-04T11:10:00+0100"),!
w $$Iso8601ToTimeStamp("2021-11-04T11:10:00+0200"),!
w $$Iso8601ToTimeStamp("2021-11-04T11:10:00-0140"),!
Iso8601ToTimeStamp(ts) {
s r=##class(%TimeStamp).XSDToLogical($e(ts,1,22)_":"_$e(ts,*-1,*))
w r," => "
q $zdth(r,3)
}Output:
USER>do ^test 2021-10-21 23:00:00 => 66038,82800 2021-11-04 10:10:00 => 66052,36600 2021-11-04 09:10:00 => 66052,33000 2021-11-04 12:50:00 => 66052,46200
In this case, you can do this:
SELECT %TSQL.ZRAND(%ID+1e16) rnd, ID, Citizenship, DOB, FirstName, Gender, IDNumber, LastName, PatientNumber, PhoneNumber FROM CDR.Patient
Type of rnd - DOUBLE.
Of course, you can convert it to NUMERIC or STRING
For debugging purposes and further query optimization, why not?
I have a legacy code that I need to optimize.
Try calling the ClearBuffers in the GLOBUFF system routine, e.g.:
USER>d ClearBuffers^|"%SYS"|GLOBUFF() Removed 65303 blocks
E.g.:
Class dc.test Extends %ZEN.Component.page
{
XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ]
{
<page xmlns="http://www.intersystems.com/zen">
<tablePane id="tp" sql="select 1 id, '2021-11-03' DT union select 2, '2022-01-24'">
<column colName="id"/>
<column colName="DT" link="javascript:zenPage.modalGroupCalendar('#(%query.DT)#');"/>
</tablePane>
</page>
}
ClientMethod modalGroupCalendar(val) [ Language = javascript ]
{
var group = zenPage.createComponent('modalGroup');
group.setProperty('onaction','zenPage.calendarAction(group);');
group.show('Select a date:','calendar',val);
}
ClientMethod calendarAction(group) [ Language = javascript ]
{
alert("You selected: " + group.getValue());
// SaveOnServer(); !
}
}Perhaps the built-in function will suit you $TSQL_NEWID()
Try this:
Class dc.test Extends %ZEN.Component.page
{
XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ]
{
<page xmlns="http://www.intersystems.com/zen">
<tablePane id="tp" sql="select 1 id, 'a' FollowUp union select 2,'b'">
<column colName="id"/>
<column colName="FollowUp" header="FollowUp Comments" width="9%" style="text-align:left;" OnDrawCell="txtFollowUp"/>
</tablePane>
</page>
}
Method txtFollowUp(
pTable As %ZEN.Component.tablePane,
pName As %String,
pSeed As %String) As %Status
{
&html<<textarea name="followup" rows="3" style=" width: 95%;" onchange="zenPage.saveFollowUp(this.value,#(%query("id"))#);">#(%query(pName))#</textarea>>
Quit $$$OK
}
ClientMethod saveFollowUp(
val,
id) [ Language = javascript ]
{
zenAlert(val,' <-> ',id);
}
}This functionality is available when working with ActiveX (however, ActiveX is not recommended for use in new applications):
PS: in the Caché distribution there was even a special library DelphiCallback.dll for Delphi, an example of working with which is in my blog.