Robert Cemper · Feb 26, 2018 go to post

You look for INSERT from Query
doc is here http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=RSQL_insert#RSQL_insertselect

As far as I see it should work the way you have written
(assuming data types between target and source match) 

To estimate runtime you may try the select count(*) from  VwSrcTable  first to get a feeling
how many records that will be. 

Then during load running Select count(*) from DestTable from a 2nd session may let you see your progress.
 

Robert Cemper · Feb 22, 2018 go to post

SQLCODE -99 Privilege violation

You have 3 different sets of access rights in this scenario

  • your  development user    
  • the application user
  • the user your Caché / ENS server installation is running on

Check if also  your server has the required access rights at OS level.
under *IX it's quite likely that you don't run as root.
(though this happens also on other OS)
 

Robert Cemper · Feb 21, 2018 go to post

An interesting observation!
IT WORKS !

I just retyped it a little bit extended for fast retry:

set minage = 80
set myquery = 3
set tStatement = ##class(%SQL.Statement).%New()
set myquery(1) = "SELECT top 10 %ID AS id, Age , Name, %ODBCOUT(DOB) DOB, Home_State"
set myquery(2) = "FROM Sample.Person WHERE Age > :minage"
set myquery(3) = "ORDER BY 2"
set qStatus = tStatement.%Prepare(.myquery)
set tResult = tStatement.%Execute()
do tResult.%Display()
in SAMPLES:
id      Age     Name                    DOB     Home_State
16      82      Schaefer,Alvin S.       1935-05-05      HI
108     82      Adams,Brian Q.  1936-02-21      IL
199     82      Yeats,Ashley K. 1935-10-28      NC
74      83      Ravazzolo,Molly I.      1934-12-31      WV
63      84      Cheng,Filomena J.       1933-12-27      NM
69      84      Yeats,Patrick U.        1933-04-19      KY
92      85      Lepon,Liza M.   1932-06-03      MN
94      87      Browne,Patricia I.      1930-04-05      AL
111     87      Orlin,Edward J. 1930-04-10      OR
197     87      Rogers,Barbara M.       1930-12-06      WI

It also works using traditional %ResultSet

Though I didn't interpret nor use it that way it is documented here:

Dynamic SQL versus Embedded SQL    (4th point)

Dynamic SQL can accept a literal value input to a query in two ways:
input parameters specified using the 
“?” character,
and input host variables (for example, :var).
Embedded SQL uses input and output host variables (for example, :var).
Robert Cemper · Feb 21, 2018 go to post

reason #1) 40 yrs. backward compatibility  
#2) in $LB not everything is a string but has its hidden data types 
while a string is sequence of bytes an integer get#s a binary representation ( ~ 19 digits ==> 8 byte (int64))
try:

set x=$lb(64444,"64444")  zzdump x
04 04 BC FB 07 01 36 34 34 34 34


it's really byte saving

Robert Cemper · Feb 20, 2018 go to post

In general I would agree:
Though in order to use the class query you have the change  to namespace "%SYS" and  back.
As the query is predefined you finally build your own lookup list which is a copy of the original global.
Anyhow this would provide the required result:

     kill roles
    set roles=""
    new $namespace
    zn "%SYS"
    set rs=##class(%ResultSet).%New("Security.Roles:ListAll1")
    set tSC=rs.Execute()
    if tSC
       {
        while rs.Next() {
            set role=rs.Get("Name")
            write ">",role,! ;; just for display
            set roles($zcvt(role,"L"))=""
       }
     set rs=""                       ;; for save return from "%SYS"
     zw roles                        ;; for demo
     set list2=$lfs(input,"CN=")
     for i=2:1:$LL(list2) {
        set CN=$p($li(list2,i),",") ;; get 1st piece
        set CN=$zcvt(CN,"L") ;; lower case required..v
        set exists=''$d(roles(CN))
        write !,i," ",exists," ",CN ;; for debugging and demo
        if exists write " role found"
        }
     quit                            ;; get back to original namespace
Robert Cemper · Feb 19, 2018 go to post
for i=2:1:$LL(list2) {
  set CN=$p($li(list2,i),",") ;get 1st piece 
  set CN=$zcvt(CN,"L")        ;lower case required..v 
  set 
exists=''$d(^|"%SYS"|SYS("Security","RolesD",CN))
  write !,i,"  ",exists," ",CN
  if exists write " role found"
}  
Robert Cemper · Feb 19, 2018 go to post

so with a little change you get the content of CN= as starting string 

set list2=$lfs(input,"CN=")
; ignore trailer
for i=2:1:$LL(list2) write !,i,?5,$p($li(list2,i),",")
 
2    Access.Ensemble.Developer.User
3    [CPD Admin]
4    [MUSE_Access]
5    [IT eMaterials]
Robert Cemper · Feb 19, 2018 go to post

what is this ?  a String or a JSON object ,  or a fixed sequence of (CN=  ,OU=,  DC=, DC= )
there is no obvious groupIng by a separator visible.
You may start by

set list=$lfs($p($p(input,"{",2),"}"))
zw list
list=$lb("CN=Access.Ensemble.Developer.User","OU=Access Groups","DC=OSUMC","DC=EDU"," CN=[CPD Admin]","OU=Distribution Lists","DC=OSUMC","DC=EDU"," CN=[MUSE_Access]","OU=Distribution Lists","DC=OSUMC","DC=EDU"," CN=[IT eMaterials]","OU=Distribution Lists","DC=OSUMC","DC=EDU...")

 

But instead of an unstructured string you have an unstructured list  

Robert Cemper · Feb 19, 2018 go to post

George, Gordon
Interesting info on Upgrade2016.1  This seems to by some fake news.
Since the class is there om 2017.2 and even in IRIS2018.1
http://docs.intersystems.com/iris20181/csp/documatic/%25CSP.Documatic.cls?PAGE=CLASS&LIBRARY=%25SYS&CLASSNAME=%25CSP.Stream

The Type set fails because %CSP.Stream is just an abstract class. 
Like %CSP.Page you have to create the real object yourself as %CSP.CharacterStream or %CSP.BinaryStream
 

a little bit simplified for retyping in terminal:

set req = ##class(%CSP.Request).%New()
set cont=req.Content zw cont   ; MO AUTOMATIC OBJECT BEAUSE ABSTRACT !!
cont=""
set cont=##class(%CSP.CharacterStream).%New()  zw cont  ; NOW WE HAVE AN OBJECT
cont=<OBJECT REFERENCE>[5@%CSP.CharacterStream]
+----------------- general information ---------------
|      oref value: 5
|      class name: %CSP.CharacterStream
| reference count: 2
+----------------- attribute values ------------------
|     (%Concurrency) = 1
|    (%LastModified) = ""
|          %Location = ""  <Get,Set>
|         (%LockRef) = ""
|          (%Locked) = 0
|              AtEnd = 0
|           (Buffer) = ""
|           (IOSize) = 0
|                 Id = ""
|     LineTerminator = $c(13,10)  <Set>
|        (MaxNodeNo) = 0
|             (Mode) = 0
|           (NodeNo) = 0
|         (Position) = 1
|        (StoreNode) = ""
|        (StoreRoot) = "^CacheStream"
|         (TempNode) = ""
+--------------- calculated references ---------------
|            CharSet   <Get,Set>
|        ContentType   <Get,Set>
|            Expires   <Get,Set>
|           FileName   <Get,Set>
|            Headers   <Get,Set>
|       LastModified   <Get>
|        MimeSection   <Get,Set>
|               Size   <Get>
|        (StoreGlvn)   <Get>
|         (TempGlvn)   <Get>
+-----------------------------------------------------
set cont.ContentType=
"application/json"

; and so on ....

HTH

Robert Cemper · Feb 19, 2018 go to post

Digging around working sets I found them unable to cover package  structures:
packages seem to be implemented as kind of sub-directory. 

You see the same effect in editor pane. The package is only visible in mouseOver event.
  

You only see the packages if you click the down arrow in right upper corner and "Edit Working Set".

For "TZ = TimeZone" I googled around Eclipse and opened a can of worms. With no answer.

Robert Cemper · Feb 17, 2018 go to post

try this

 set list=$lb("","2",6,6,6,"3")
   ​for i=1:1:$LL(list) { write !,$li(list,i),?5
      if $lb($li(list,i)) = $lb(+$li(list,i))  write "Integer"
      else  write "String"
   }

 Result:

     String
2    String
6    Integer
6    Integer
6    Integer
3    String 

Robert Cemper · Feb 17, 2018 go to post

This functionality seems to be broken. Since quite some time.
It also fails in SAMPLES /  Class ZENTest.ComboTest.cls and the method
is never called.
Analysis of   Class %ZEN.Component.
dataListBox  shows that the related call to method %DrawItem got lost.

I verified it with a personal hack. 

You may contact WRC for a fix.

Robert Cemper · Feb 16, 2018 go to post

if you just want to eliminate the hyphen this may work for you:

USER>write $TR($zcvt($tr("mY-sImPlE eXaMpLe","-"," "),"W")," ")
MySimpleExample


translate hyphen to blank  first and off you go  

Robert Cemper · Feb 16, 2018 go to post

provided you have sufficient access rights you may get defined roles in Caché / Ensbele like this:

 set role=""
 for   {
     set role=$ORDER(^|"%SYS"|SYS("Security","RolesD",role)) quit:role=""  
     write role,!    ;; or do whatever you need
     }
Robert Cemper · Feb 16, 2018 go to post

I probably don't understand your expectation.

You upload typically an image or something similar that the browser
can display as part of the article, questions, answer, comment you write.
And that works excellent.
If this is something else e.g. some binary stuff, or Word.doc or Excel it may fail.
What type of file would you expect to upload ?  

Robert Cemper · Feb 16, 2018 go to post

Ooops!

The sequence of recruiters seems to be reversed related to values
 

Gold Recruiter - 10 referrals

Awarded after 10 / 50 / 100 of your referrals have joined Developer Community.

Silver Recruiter - 50 referrals

Bronze Recruiter - 100 referrals

Robert Cemper · Feb 14, 2018 go to post

Oliver,

this turned out to be somewhat more tricky than expected.
The way you used stream.FindAt(...)  returns the size of the gap between the last found occurrence and the next.
So you have to add the size of your search string for each loop to get closer to your file size

so it might be easier to do it this way:

set last=1
for  set i=stream.FindAt(last,"Invalid password") quit:i<0  set last=i

this might be closer but definitely smaller than the total size  

Robert Cemper · Feb 14, 2018 go to post

it says:

If it does not find the target string then return -1

So what you get in i is the last start of your search string

              Which is 2491024949 - 2442920326 = 48104623 from end.
It's almost the same as your first occurrence at 49134354. Looks feasible.

To get the file size as you expect the LAST search string must have been  starting
AT 
the end of your file. Which is a contradiction.

Robert Cemper · Feb 14, 2018 go to post

your code: from Docs:

set i=stream.FindAt(-1,"Invalid password",x)+i

from Docs:
 

Find the first occurrence of target in the stream starting the search at position.
It returns the position at this match starting at the beginning of the stream.
If it does not find the target string then return -1.
If position=-1 then start searching from the current location and just return the offset from the last search,
useful for searching through the entire file.
If you are doing this you should pass in tmpstr by reference in every call which is used as
a temporary location to store information being read so the next call will start where the last one left off.
If you pass caseinsensitive=1 then the search will be case insensitive rather than the default case sensitive search.

 
So your line should work like this
while(stream.AtEnd=0){set i=stream.FindAt(-1,"Invalid password",.x)+i}
-----------------------------------------------------------------^
PASS BY REFERENCE should do the trick
Robert Cemper · Feb 13, 2018 go to post

Since the time when there was a Projection to C# I have adopted unique names.
It was an incredible pain if names were not unique.
 

Robert Cemper · Feb 12, 2018 go to post

Congratulations! yes
The call to server is only necessary if you provide some tricky calculations at server side