Robert Cemper · May 13, 2018 go to post

Pls. forget "store it as it is" all you store is the oref (a pointer to a local structure) with no persistent storage behind.

set local= dynamicObject.%ToJSON()
set classObj.Test = "my dynamicObject = "_$LENGTH(local)

so you don't get an error if you just apply  %ToJSON()  ???

 If your version is before 2016.2  than .$toJSON() would be the right method

Robert Cemper · May 13, 2018 go to post

You didn't indicate the line you get the error.
anyhow the message is clear:
Either classObj or dynamicObject is not what you expect it to be.
If you test from Terminal you can use

ZWRITE classObj
ZWRITE dynamicObject

to see what they are.

otherwise, you may comment out one line and see if it still breaks e.g.

// set local= dynamicObject.%ToJSON()
set classObj.Test = "my dynamicObject = "_$ISOBJECT(dynamicObject)

So you see what happens.  I expect:  my dynamicObject = 0

So you see where you have to investigate further

Robert Cemper · May 12, 2018 go to post

is it defined that way?
Property Test as %String (MAXLEN="") ;

ATTENTION - default MAXLEN = 50 !!!!!

This might look odd but try

set local= dynamicObject.%ToJSON()
set classObj.Test = local

 
so you see if the issue is your property  
or your dynamic Object. as there are 2 objects in the command.
the only thing %String is checked against is Length. 
otherwise. if %ToJSON() fails your dynamic object is broken somehow

Robert Cemper · May 12, 2018 go to post

Peter,
I have the same problem. (and some more others). It's good not to feel alone. smiley

Robert

Robert Cemper · May 12, 2018 go to post

If you check it in the same process it's of course there as you are still in the same local partition (environment).
but you need it in your message that gets handled by some other process that has no access nor idea about your local environment.

which is the essential concept of all those message structures.

Robert Cemper · May 12, 2018 go to post

You can't just set the dynamic object (exactly the oref) to  %String.
You place than just a reference of a local structure to your message.  That's useless.
you need to 

Set classObj.Test = DynamicObject.%ToJSON()

Now you have your string that gets persisted and is part of your message.

Suggested reading: Converting Dynamic Entities to and from JSON​

Robert Cemper · May 12, 2018 go to post

I guess you did this intentionally to challenge your readers wink

I may may mistakes or miss a better way of doing things

I highly appreciate your series of articles.

yes
 

Robert Cemper · May 12, 2018 go to post

just try a restart of Eclipse.
When fresh stated it is sometimes so busy with its own updates  

Robert Cemper · May 12, 2018 go to post

Any message in Ensemble is a persistent object.
If you persist your dynamic object as (long)  %String or %Stream it should get sent

Robert Cemper · May 11, 2018 go to post

I'd recommend JAVA, JDBC Cache, SQL it's a strong and fast combination with strong support,

VB6 is far out of date
VisM is a remainder from before Caché times.

So it's rather an issue of compatibility, maintenance, support  than performance

Objects vs. SQL is depending on what you try to achieve.
Object access is can be an advantage for large and complex objects that you need as a whole item.
As you mention VB6 + VisM the original author probably wasn't very comfortable with SQL at his time.
 

Robert Cemper · May 10, 2018 go to post

Have you tried to set it back to %String manually?
There should be no issue from Ensemble side
 

Robert Cemper · May 10, 2018 go to post

Welcome to the Caché world!

There is NO limit on commands to be executed !
Don't worry about the number. SQL is consuming a lot of commands.
And Class Queries in %SYS by its nature may even consume more than standard SQL queries.
Just during a quick check of your code example I passed 700k.

A general hint on programming style:
Pls. try to avoid Dot Style and use curly brackets instead. 
This is a very old notation. Not as old as Hieroglyphs, but almost smiley

What I mean. instead of

  I Rset.GetData(1) = Pid D
    . w !,Rset.GetData(1)," ",ClientIPAddress," ",Pid
            //Set rs=$SYSTEM.Process.Terminate(Pid)
            //If rs'=1 {
            //    Write "Terminate Fialure "_" Pid "_Pid,!
            //}
            //Else {
            //    W "Sucess",!
        //    }
    //    }

use 

  I Rset.GetData(1) = Pid {
     w !,Rset.GetData(1)," ",ClientIPAddress," ",Pid
            //Set rs=$SYSTEM.Process.Terminate(Pid)
            //If rs'=1 {
            //    Write "Terminate Fialure "_" Pid "_Pid,!
            //}
            //Else {
            //    W "Sucess",!
        //    }
    //    }
    }

 This makes it much easier for the audience to follow your code, and it is actual coding style,
 

Robert Cemper · May 9, 2018 go to post

Congratulations!

docs say:

  Sends any buffered output out the TCP connection; that is, executes a TCP SEND operation on the data in the output buffer.
If the data is compressed (/GZIP) stream data, *-3 sends the data without marking the compression endpoint.

I interpret this: 
up to some limit, it is sent somehow automatically
and the eventual rest needs to be pushed out manually or gets never sent or is to late.

???  surprise

Robert Cemper · May 9, 2018 go to post

is it persistent across different browsers ?

IF YES -> our problem,
OR do you see different cut off lengths.
 I especially distrust IE !
 

Robert Cemper · May 9, 2018 go to post

Eduard,

I googled around "max url lenght"  and found
#1 browser depending
#2 limit yourself to 2048 char.
So is your redirect just URL or  URL?urlparams=...... 

Robert Cemper · May 9, 2018 go to post

I added it just to the end. But thas nit important.

Did you also add at the end this: ??

Storage GSQLStorage
{
<StreamLocation>^
Mike.StreamS</StreamLocation>
<Type>%CacheSQLStorage</Type>
}

If this is missing the class also doesn't compile. 
the name of the global for streams is not important.

BT: What error did you get ?

Robert Cemper · May 9, 2018 go to post

- you have

Parameter CONNECTION = "canreg,NOCREATE";

- so the name of your Gateway definition is canreg 
- you have no storage for streams defined.
Strange but might be an issue of Caché version version issue.
in 2016.2 it just doesn't compile without.
- more strange is this:

Index MainIndex On null [ IdKeyPrimaryKey ];

The property null doesn't exist in your class.
Without a property null  it doesn't compile for me.

adding manually the missing Storage section and 

Property null As %Integer;

let it compile for me. 

Though this may be a temporary fix I distrust your Link Wizard.
Eventually, you should contact WRC  to investigate the reason.

Robert Cemper · May 8, 2018 go to post

You are right!  
And I'm not aware of a different behavior.  Except:  oops!

Robert Cemper · May 8, 2018 go to post

I just can guess for possible reasons
- dependencies in parallel compiling 
- some kind of complex or circular "CompileAfter" constructs 

those things often vanish at 2nd compile with freshly loaded classes.  (Hard to reproduce.)

Robert Cemper · May 7, 2018 go to post

I finally got the code to compile with no errors.
When I run it, the code will insert a row in the table "global" in 
cache.
However, it isn't inserting the information in the external database.

From what you describe you have generated a Local Table
as there is a GLOBAL and you write to your local DB. As you have seen.

If you use Link Table Wizzard to create it, then there is just no global.
The correctly generated class looks similar to this:

/// Generated by the Link Table wizard on 2018-05-07 23:20:46.
Note that you can access the data in this class only when the external database is accessible
.

Class GTY.Person Extends %Library.Persistent [. . . . , StorageStrategy = GSQLStorage ]
{
/// Specifies details for the SQL Gateway Connection that this class uses
Parameter CONNECTION = "
. . . . . . ,NOCREATE";
.......

Storage GSQLStorage
{
<StreamLocation>^
####S</StreamLocation>
<Type>%CacheSQLStorage</Type>
}

}

If you do not see the bolded text in your class,
it is not generated by Link Table Wizard and
you are in the wrong Class / Table with no access to he external table.

Robert Cemper · May 7, 2018 go to post

only 1 .int in %SYS uses "oops:"
MIRRORCOMM.int(2845): if $zb(+$SYSTEM.Mirror.DebugFlags(),1,1) do $zu(9,"","oops: jrn.log has incorrect entry, exp("_newpath_") logentry("_jrnfname_"), file num-"_mirfilecnt)
 

 could be an indicator to some MIRROR issue

Robert Cemper · May 7, 2018 go to post

Could it be there was some Tune Table running that saves its statistic in Storage part of Class ?

BTW. oops is really new style surprise

Robert Cemper · May 7, 2018 go to post

2 steps:

  • create the new table EMS.BASIC
  • INSERT INTO EMS.BASIC (Name,DOB,Gender) Select Name,DOB,Gender from EMS.EMS
Robert Cemper · May 7, 2018 go to post

There is a bunch of useful articles you find here searching for CSV.

I just picked one out of them: 
https://community.intersystems.com/post/how-read-csv-file-contents-objects-cache

In a Windows environment, you may also use an ODBC driver (DSN) and handle
Excel as what it is: As a Table using the SQLgateway as you would to with other DBs

You just have to take care to get the bits matching  (32/64). More details:
https://support.office.com/en-us/article/overview-of-connecting-to-importing-data-c0ad7aec-ff1a-4e48-9c21-dc18a102433f
 

Robert Cemper · May 4, 2018 go to post

Yes.  Connect to Mirror using SQLgateway.
Link Procedure And then just to a SELECT or CALL.
The code has, of course, to be prepared already on Mirror.

Robert Cemper · May 3, 2018 go to post

as Jeff mentioned: the Shadowed DB is Read Only.

Execution of some code in a remote instance of Caché is independent of Mirror or not

  • Either pack your code (or its call) into a ClassMethod with a return value.
    mark the Method as  [SqlProc ]
    trigger it by SELECT my.procedure()
  • Or wrap it into some WebService ( REST, SOAP) and execute it that way. 
Robert Cemper · May 3, 2018 go to post

if ever this should be of practical use
then I'd suggest to move such a "everybody's darling" routine to %SYS and name it %zYJM

Robert Cemper · May 3, 2018 go to post

I agree and have suffered over years.
I think for Caché and its  derivates it's somewhat late in the life cycle.
Eventually with iris ?  Should be worth an enhancement request