In IRIS this property is hidden in contrast to Caché:
By the way this also doesn't work in IRIS anymore: Is there a way to get [ Internal, Private ] property?- Log in to post comments
In IRIS this property is hidden in contrast to Caché:
By the way this also doesn't work in IRIS anymore: Is there a way to get [ Internal, Private ] property?You can solve the issue "head-on", namely, to re-convert character stream using %IO.StringStream:
Class dc.test [ Abstract ]
{
ClassMethod test()
{
s char="тест",
bin=$zcvt(char,"O","UTF8")
w "dump char:" zzdump char
w !!,"dump binary:" zzdump bin
w !!,"Char:",?21,$system.Encryption.Base64Encode($system.Encryption.SHAHash(256,char)),!,
"Binary:",?21,$system.Encryption.Base64Encode($system.Encryption.SHAHash(256,bin)),!!
s cs=##class(%Stream.TmpCharacter).%New()
d cs.Write(char)
s stream=##class(%IO.StringStream).%New()
s stream.CharEncoding="UTF8" ; here should be the encoding of your CSV file
d stream.CopyFrom(cs) ; or d stream.CopyFrom(source.Stream)
s stream.CharEncoding="Binary"
/*
Attention! The following code is needed to work around an error in method the SHAHashStream,
since it expects "Rewind() As %Status", but class the %IO.StringStream uses "Rewind(Output pSC As %Status)"
*/
s bs=##class(%Stream.TmpBinary).%New()
d bs.CopyFrom(stream)
w "Char (stream):",?21,$system.Encryption.Base64Encode($system.Encryption.SHAHashStream(256,cs)),!,
"Binary (stream):",?21,$system.Encryption.Base64Encode($system.Encryption.SHAHashStream(256,bs)),!!
}
}
Result:dump char: 0000: 0442 0435 0441 0442 тестdump binary: 0000: D1 82 D0 B5 D1 81 D1 82 Ñ.еÑ.Ñ.
Char: 2eEII+27ZRfvbZvK4XNsx7WPDb+82DymPPOAdJ0p1SQ= Binary: 409t7BLE9FmeugePMa6BOUINIbG9LXztfSKwnCB0+0g=
Char (stream): 2eEII+27ZRfvbZvK4XNsx7WPDb+82DymPPOAdJ0p1SQ= Binary (stream): 409t7BLE9FmeugePMa6BOUINIbG9LXztfSKwnCB0+0g=
Also, I advise you to look at CacheActiveX instead of VisM, which has restrictions on the size of the transmitted data. Here is my old article on this subject: link to machine translation
COS: #include %systemInclude main() s PLIST=2 s PLIST(1)="line 1" s PLIST(2)="multiline 1"_$$$NL_"multiline 2" q 1
DELPHI:
procedure TForm1.Button1Click(Sender: TObject);
begin
VisM.Server:='cn_iptcp:127.0.0.1[1972]:_system:@SYS';
VisM.NameSpace:='USER';
VisM.Execute('$$main^dc');
ListBox.Clear;
ListBox.Items.Text:=VisM.PLIST;
end;| line 1 |
| multiline 1 |
| multiline 2 |
Try change TranslateTable:
Class dc.test [ Abstract ]
{
ClassMethod runtests()
{
;d ##class(dc.test).runtests()
s data="тест"
w "data: ",?15,data,!
s cs=##class(%Stream.FileCharacter).%New(),
cs.Filename="C:\Temp\test.txt",
cs.TranslateTable="UTF8"
d cs.Write(data),
cs.%Save()
s bstream=##class(%Stream.FileBinary).%New()
d bstream.LinkToFile(cs.Filename)
w "Binary:",?15,$system.Encryption.Base64Encode($system.Encryption.SHAHashStream(256,bstream)),!
s cstream=##class(%Stream.FileCharacter).%New()
d cstream.LinkToFile(cs.Filename)
w "Char:",?15,$system.Encryption.Base64Encode($system.Encryption.SHAHashStream(256,cstream)),!!
s cstream.TranslateTable="" ;or RAW, SAME
w "Char->Binary:",?15,$system.Encryption.Base64Encode($system.Encryption.SHAHashStream(256,cstream))
}
}
USER>d ##class(dc.test).runtests()
data: тест
Binary: 409t7BLE9FmeugePMa6BOUINIbG9LXztfSKwnCB0+0g=
Char: 2eEII+27ZRfvbZvK4XNsx7WPDb+82DymPPOAdJ0p1SQ=
Char->Binary: 409t7BLE9FmeugePMa6BOUINIbG9LXztfSKwnCB0+0g=$EXTRACTdoc
Keep in mind that
Characters are counted from 1.
, so instead
$EXTRACT({LabName},0,3)
should be
$EXTRACT({LabName},1,3)
In this case, it is uncritical, because
If the from value is 0 or a negative number, $EXTRACT returns a null string; however, if from is used with to, a from value of 0 or a negative number is treated as a value of 1.
But in other cases it can lead to the wrong result.
That would work storagetime but not at runtime.
It was just a matter of ease of accessing data using SQL. No more than.
Who knows, maybe the author just decided to use SQL to identify duplicates?
I think runtime hook disallowing duplicate inserts would be better.
I agree. But this is a completely different task and is solved in a different way.
Like this:
Property Actor As list Of packet.Actor(POPSPEC = ".ActorFilter():10") [ Required ];
Method ActorFilter() As %Integer
{
set actorID=$random(10)+1
for i=1:1:$order(i%Actor(""),-1) return:actorID=$list(i%Actor(i),1) ""
quit actorID
}The author after all asked about SQL therefore I above and asked to specify that it is necessary actually.
There are a couple of comments:
Class packet.Actor Extends (%Persistent, %Populate)
{
Property Name As %String [ Required ];
Index NameIndex On Name [ Unique ];
Property Age As %Integer (MAXVAL=100, MINVAL=10) [ Required ];
Index AgeIndex On Age [ Unique ];
Property Sex As %String (DISPLAYLIST=",Woman,Man") [ Required ];
}better
Class packet.Actor Extends (%Persistent, %Populate)
{
Index NameIndex On (Name, Age) [ Unique ];
Property Name As %Name [ Required ];
Property Age As %Integer(MAXVAL = 100, MINVAL = 10) [ Required ];
Property Sex As %String(VALUELIST = ",Woman,Man") [ Required ];
}Otherwise it will not be possible to insert two or more persons with the same age. Or do you specifically want it?
This code contradicts the documentation (Specifying the POPSPEC Parameter for List Properties):
Leave basicspec empty if the property is a list of objects.
However, in this case, ActorFilter() should return strictly one ID, not a collection.
select * from packet.Movie where $listbuild('6') %inlist Actor
It seems to me that in your case it would be easier to do so:
Property Actor As list Of packet.Actor(STORAGEDEFAULT = "array") [ Required ];
Then the query will be simplified:
select * from packet.Movie_Actor where Actor=6
Or even so
select * from packet.Movie where Movie_Actor->Actor=6
Hi, Yana!
Give the class code, the source data and an example of what you want to get in the end.
If we have a lot of votes will consider to add it.Do we still have to vote for this?
On-my enough one moreover, that moderators (you and Dmitry) and engineers InterSystems (Eduard, Alexander, Anton, Sergey, Anastasia, Timur, etc.) - Russian-speaking.
I have one problem with it - if we introduce Russian Community, will you stop answering questions in English?)
When will Russian language support be available?
Property Product As %String [ Required ];
Property Item As %String [ Calculated, SqlComputeCode = { s {*}=$e({Product},1,5)}, SqlComputed ];
it is better to use
Property Product As %String [ Required ];
Property Item As %String(MAXLEN = 5) [ Required, SqlComputeCode = { s {*}=$e({Product},1,5)}, SqlComputed, SqlComputeOnChange = Product ];
SELECT * FROM Portal.ProductStats ps left JOIN Portal.ProductCacheUpdates pcu ON (pcu.Item=ps.Item) WHERE ps.Item=?
Relative cost = 1338 ◾Read master map Portal.ProductStats.IDKEY, looping on ID. ◾For each row: Read index map Portal.ProductCacheUpdates.pcacheUpdsProd, using the given %SQLUPPER(Item), and looping on ID. For each row: Read master map Portal.ProductCacheUpdates.IDKEY, using the given idkey value. Generate a row padded with NULL for table Portal.ProductCacheUpdates if no row qualified. Output the row.
Relative cost = 1219.2 ◾Read index map Portal.ProductStats.pcacheUpds, using the given %SQLUPPER(Item), and looping on ID. ◾For each row: Read master map Portal.ProductStats.IDKEY, using the given idkey value. Read index map Portal.ProductCacheUpdates.pcacheUpdsProd, using the given %SQLUPPER(Item), and looping on ID. For each row: Read master map Portal.ProductCacheUpdates.IDKEY, using the given idkey value. Generate a row padded with NULL for table Portal.ProductCacheUpdates if no row qualified. Output the row.
As you can see in both cases the index pcacheUpdsProd is used.
Have you really set up the tables and cleared the cached queries so that the optimizer can start using the new statistics?
Try to do it manually in the terminal:
blablabla>d $system.SQL.TuneSchema("Portal",1), $SYSTEM.SQL.Purge(), $system.Status.DisplayError($system.OBJ.CompilePackage("Portal","cu-d"))The documentation describes in detail how and why.
For example, sometimes the optimizer decides not to use the index if a full crawl would be more efficient. It depends on many parameters: ExtentSize, Selectivity, etc.
Give here what Robert asks, and it will be possible to tell more precisely why.
[Caché SQL Optimization Guide > Introduction to SQL Performance Optimization]
In most cases, helps "tune table". But you can try hints (%ALLINDEX, %FIRSTTABLE, etc.)
Try this:
update RB_ResEffDateSessPayorRestr set RESTR_DATETo=to_date(DATEADD('year',1,RESTR_DATETo),'YYYY-MM-DD') where YEAR(RESTR_DATETo)=2020Or this:
update RB_ResEffDateSessPayorRestr set RESTR_DATETo=%odbcin(DATEADD('year',1,RESTR_DATETo)) where YEAR(RESTR_DATETo)=2020&SQL(SELECT ID FROM Cinema.Film ORDER BY ID DESC)
similar to the query
&SQL(SELECT TOP ALL ID FROM Cinema.Film ORDER BY ID DESC)
&SQL(SELECT TOP ALL ID FROM Cinema.Film ORDER BY ID DESC)
and
&SQL(SELECT TOP 1 ID FROM Cinema.Film ORDER BY ID DESC)
are so significantly different.
Class dc.test Extends %RegisteredObject
{
ClassMethod Run(
a,
b)
{
w $$$FormatText("a=%1, b=%2",$g(a,"<null>"),$g(b,"<null>")),!
}
ClassMethod Test()
{
s cName="dc.test",
mName="Run",
args=2,
args(1)="2019-01-01",
args(2)="1,2,3,4"
d $classmethod(cName,mName,args...)
k args
s args=1,
args(1)=77
d $classmethod(cName,mName,args...)
k args
s args=2,
args(2)=33
d $classmethod(cName,mName,args...)
k args
s args=""
d $classmethod(cName,mName,args...)
}
}
Result:
USER>d ##class(dc.test).Test()
a=2019-01-01, b=1,2,3,4
a=77, b=<null>
a=<null>, b=33
a=<null>, b=<null>
The field TimeCreated is of type Ens.DataType.UTC.
Then so:
datepart('hh', %external(TimeCreated))
It's a challenge. Give a reproducible example for "play around". There are a bunch of hints: Query Optimization.
@Kyle Baxter will also be interested in your issue.
At me in SMP the following query returns 23:
select datepart('hh', {ts '2019-09-10 23:01:45'})By default, the mac address of the computer on which the DBMS instance is running is returned. But you can get the mac address of any other computer, see getmac /?.
I checked for versions 2009.1/2010.1: unfortunately, the $zu(114,0) returns nothing, therefore, remains variant with the command line.
Example for Windows, provided that the system has a single network card:
#include %syConfig
n result
w $zu(144,1,$$$DEFETHADDR),!,"------",!
d $system.OBJ.DisplayError(##class(%Net.Remote.Utility).RunCommandViaCPIPE("getmac /NH /fo table",,.result))
w $p(result," ",1)PS: for other OS command line may be different.
I know. After all the author requested the solution on pure M and not COS.
Try this:
w $zu(114,0) or w $$$DEFETHADDR ; from %syConfig.inc
Important note: it should be noted that the proposed solutions refer only to the port of the private web server, which may not even be installed. In the case of an external web server, this is not possible.
Thank you for your comment. This code is taken from the source code %SYS, which in theory should be an example for application developers.
I hope that InterSystems developers will see your comment and make appropriate changes.
Intel i5-2400
10000 digits ~ 58 sec.
calcPI(n) public {
s $lb(len,nines,predigit,r)=$lb(10*n\3,0,0,"")
f i=1:1:len s a(i)=2
f j=1:1:n {
s q=0
f i=len:-1:1 s x=10*a(i)+(qi), a(i)=x#(2i-1), q=x(2*i-1)
s a(1)=q#10, q=q\10
i q=9 {
s nines=nines+1
}elseif q=10 {
s r=r(predigit+1)$$repeat^%qarfunc(0,nines), predigit=0, nines=0
}else{
s r=rpredigit, predigit=q
s:nines r=r$$repeat^%qarfunc(9,nines), nines=0
}
}
q r_predigit
}Certainly.
And if so?
w $zobjref(^||PPG(1)).Name
Still take a look at $$$objOrefToInt/$$$objIntToOref (%occObject.inc)
PS: it should be noted that OREF ≠ OID and serve different purposes.