Caché up to 2018.1 and early versions of IRIS didn't have this
%sqlc. ..... feature
- Log in to post comments
Caché up to 2018.1 and early versions of IRIS didn't have this
%sqlc. ..... feature
The typical compilation sequence goes from
XML -> CLS -> INT -> OBJ <-> OBJ
The practical execution just happens at OBJ level.
For simple cases, the names of all steps might be guessed
except for the OBJ level with embedded SQL or similar
which typically compiles into some
do $classmethod("%sqlcq."_$tr($namespace, .......
and that's the deeper cause to take care for a working compilation
.Fix your sources first to have a consistent package.
Anything else is just wasted time
Thank you, Rob for your example. (Somewhat late as I was offline this week)!
I like the idea to use a series of ZI with no ZSAVE is great.
Similar to run some external code using $CLASSMETHOD()
a perfect solution
Awaiting Review simply says that no member has written a review yet
that was approved for publishing.
Actually, out of 1236 packages
959 have a review which is ~77.7% since start of OEX
It could take hours but also years
To clarify things:
Example:
06/10/26-22:00:23:437 (14644) 0 [Generic.Event] Dismounted database c:\intersystems\iris242\mgr\uiris\
That's what you you have to scan if you chase the transition
only technical blogs by human contributors
I skip replies from DC AI Bot by default
Hi Robert,
I don't know this code, though it looks somewhat familiar.
In the old times, it was rather common practice to
customize some system utilities or mix them up to
adjust them for special requirements
or might be imported from some other M version
The naming %K derived from some %G* points that direction.
Best regards, Robert
located in the middle of the European continent,
I'm watching the increasing influence of AI from all sides.
Some look fine, some others more frightening
En attendant l'approbation de l'administration d'OEX
until the OEX review is approved by admin
When I was teaching ObjectScript, the first exercise was a game "6 from 45'
The expectation is a total equal distribution.
Check the influence by the number of loops. Are there any patterns visible ?
You describe exactly the traditional multi-class/multi-table split
that I mentioned (and was too lazy to type) in my recent article
Hand crafted partitioning
🌻
set Names="A,B,Y,Z"
set A=$L(Names,",")
for I=1:1:A set G="^"_$LI($LFS(Names),I) set @G="" write $zr,! not correct. SINGLE line ELSE is part of Objectscript since ever
You just need a double space after the ELSE
USER>p
ck read "?",x,!
if x?.N write "numeric",!
else write "other",!
goto ck
USER>d ck
?5
numeric
?a
other
As almost any AI it lives from already posted questions
If the subject was never touched before, there is just no chance of finding a suitable answer
Example #5): I have never met any question related to the COS follows operator ]
Example #2) I never met any mention of global ^ROUTINE or ^rOBJ or similar
So where might the knowledge come from if never been mentioned before ?
There are several hurdles to consider:
Quite a can of worms.
You may create an SQL PROCEDURE to serve your needs:
CREATE PROCEDURE %Z.NSPACE() RETURNS VARCHAR
Language ObjectScript
{
set (%,%r)=""
for set %=$o(^|"%SYS"|SYS("CONFIG","CACHE","Namespaces",%)) quit:%="" set %r=%r_%_";"
quit %r
}and it runs like this, assuming you have access to Namespace %SYS
USER>do $system.SQL.Shell()
SQL Command Line Shell
----------------------------------------------------
The command prefix is currently set to: <<nothing>>.
Enter q to quit, ? for help.
USER>>select %Z.NSPACE()
3. select %Z.NSPACE()
Expression_1
%ALL;%SYS;DOCBOOK;SAMPLES;USER;
1 Rows(s) Affected
statement prepare time(s)/globals/lines/disk: 0.0006s/5/160/0ms
execute time(s)/globals/lines/disk: 0.0005s/6/425/0ms
cached query class: %sqlcq.USER.cls4
---------------------------------------------------------------------------
USER>>Instead of
var CS = "Server=XXXXX;User=system;Password=sys;";
This may work
var CS = "Server=XXXXX;User=_system;Password=sys;";
_SYSTEM (with leading underscore !!) is the default System Manager User
not sure if sys or SYS for password (in Caché)
And YES you should use namespace %SYS
THANK YOU @Dmitry Maslennikov for this excellent insight into the probably
most important internal structure element of IRIS and its data type variations.
As you mentioned, InterProcessCommunication, it might be worth taking
a look at my Article + Demo on OEX
Using Interjob Communication (IJC) + InterJob-communication
You should use the system variable $KEY to get input the terminator
doc in $KEY
suggested code:
USER>read *in set key=$key
;; after arrow back
USER>ZZDUMP in,key
0000: 32 37 27
0000: 1B 5B 44 .[Dso you get the full escape sequence in the variable key
or just 08 for backspace, .....
It is possible by using $replace function: some string to a different string
you define your fractional codes and run them in iterative loops
USER>read txt
¼ test character and ½ test character and ¾ test character and
USER>s a14=$c(188)
USER>s a12=$c(189)
USER>s a34=$c(190)
USER>s a17=$c(8528)
USER>write $replace($replace(txt,a14,"1/4"),a12,"1/2")
1/4 test character and 1/2 test character and ¾ test character and
USER>Attention:
Some codes are wide characters: this makes the replacement tricky
example. 1/7 >> $c(8528) !!
Basically, this query might provide the content you are looking for:
SELECT distinct TableName FROM Ens_Util.LookupTableor simply $LB formatted output:
SELECT List(distinct TableName) FROM Ens_Util.LookupTableor as JSON Array
SELECT JSON_Array(tablename) json from (
SELECT List(distinct TableName) tablename FROM Ens_Util.LookupTable)
Embedded SQL &SQL(.-.-.-)
doesn't allow variables for Table names.
You should use %SQL.Statement instead
Set tTable = "%ZZ.resultset"_ tStamp
set sql=1
set sql(1)="DROP TAQBLE "_tTable
set statement=##class(%SQL.Statement).%New()
set result=statement.%ExecDirect(.statement,.sql)
write result.%SQLCODE
To achieve this in SMP, declare your ClassMethod As SqlProcedure like this:
ClassMethod Export(nspace = "", query As %String = "") As %Integer [ SqlName = ZZEXPORT, SqlProc ]
{
new $namespace
;; and so onThen you can run it from SMP using this SQLprocedure as Static WHERE condition.
SELECT * from %ZZ.resultset
WHERE ZZEXPORT('SAMPLES',
'SELECT TOP 5 Description, ErrorStatus, Priority from ENS.MessageHeader')=0Using a TEMPORARY table avoids problems if running in more than 1 instance in parallel.
Sorry,
The new Editor is not so well-suited for long line replies. I dislike it.
The demo is designed for large screens
icons are almost invisible, small, and text is more guessing than reading
White on black is not everyone's choice
I composed a variant that doesn't require any code in ENS.
It can all run from your ONS namespace.
All you need is a valid SQL SELECT statement
First, the utility class:
Class User.ZZ [ Abstract ]
{
ClassMethod Export(nspace = "", query = "") As %Integer
{
new $namespace
zn:$l(nspace) nspace
&SQL(DROP TABLE %ZZ.resultset)
; default just for demo
set:'$l(query) query="SELECT TOP 5 ssn, home_state,name from Sample.employee"
;
set sql=2,
sql(1)="CREATE GLOBAL TEMPORARY TABLE %ZZ.resultset as ",
sql(2)=query
set statement=##class(%SQL.Statement).%New()
set result=statement.%ExecDirect(.statement,.sql)
quit result.%SQLCODE
} }a quick demo:
USER>set select="SELECT TOP 3 home_state,name,SSN from Sample.employee"
USER>w ##class(ZZ).Export("SAMPLES",select)
0
USER>:sql
SQL Command Line Shell
----------------------------------------------------
[SQL]USER>>select * from %ZZ.resultset
5. select * from %ZZ.resultset
| Home_State | Name | SSN |
| -- | -- | -- |
| NC | Emerson,Xavier O. | 217-28-9642 |
| CO | Malkovich,Bob V. | 226-71-5540 |
| UT | Joyce,Juanita V. | 396-77-7486 |
3 Rows(s) Affected
statement prepare time(s)/globals/cmds/disk: 0.0579s/39,198/181,087/0ms
execute time(s)/globals/cmds/disk: 0.0002s/4/815/0ms
query class: %sqlcq.USER.cls73
----------------------------------------------------------
[SQL]USER>>cos ZN "SAMPLES"
[SQL]SAMPLES>>select * from %ZZ.resultset
6. select * from %ZZ.resultset
| Home_State | Name | SSN |
| -- | -- | -- |
| NC | Emerson,Xavier O. | 217-28-9642 |
| CO | Malkovich,Bob V. | 226-71-5540 |
| UT | Joyce,Juanita V. | 396-77-7486 |
3 Rows(s) Affected
statement prepare time(s)/globals/cmds/disk: 0.0552s/39,198/181,087/0ms
execute time(s)/globals/cmds/disk: 0.0002s/4/815/0ms
query class: %sqlcq.SAMPLES.cls92
--------------------------------------------------
[SQL]SAMPLES>>q
SAMPLES>hope this helps:
The temporary table is visible from both namespaces
And the utiltiy is not tied to a specific query or table
All just runs and exists in your process.
Also no traces in the Journal
I was just running it without any problem in Windows Docker Desktop
Some preparation:
No problems with build
Start also OK