Warlin Garcia · Jul 2, 2018 go to post

Code placement depends on what you're trying to do and when: if processing the event from javascript (ajax call) then your code must be separate from OnPreHTTP(); if processing on the server (after page submit) then your code should be in OnPreHTTP() or called from it (this last part depends on your coding style - jam everything in a single method or separate things in multiple smaller methods)

In simple terms (as Robert pointed out) , OnPreHTTP needs to handle any processing the server must perform prior to "displaying"/"printing" the page on the browser.

Warlin Garcia · May 30, 2018 go to post

Correct. The alternative using TextReader was to "avoid" increasing memory but if you have that option then the answers provided by Timothy are the way to go.

Warlin Garcia · May 30, 2018 go to post

Understand. I haven't tried this myself yet but in theory you should be able to initialize the Reader with an XML.Document object. This Document can be initialized (%OnNew) with a global of your choice in the same manner that TextReader can. 

Warlin Garcia · May 30, 2018 go to post

For large files I use %XML.TextReader.ParseFile(). It allows me to pass a "concrete" global instead of using Cache defaults. Usually CacheTemp which is more limited than a concrete global. With this I'm able to process larger files. Granted, it's a little bit of more work (code) as you have to traverse the results (element by element) but it gets the job done.

Warlin Garcia · May 11, 2018 go to post

There's certainly a performance gap. The significance depends on what you're trying to do. For most jobs it'll be very very insignificant.  In general SQL is a little bit faster than Object access, however Object access provides other benefits in terms of code clarity and reusability. In the case of interacting with Cache from other languages (e.g Java/Spring) then SQL will be preferred for lots of reasons. The main one being that SQL, as Robert Cemper said, it's a well supported and known language. 

Warlin Garcia · May 7, 2018 go to post

Do you mind sharing what are you trying to accomplish that you need a dynamic table creating mechanism?

Warlin Garcia · Apr 30, 2018 go to post

These are compiler instructions. Not sure if the instructions change based on the cache installation language (e.g. English vs. Portuguese). You can change the language for Studio based on your locale but that's only for menus and such.

Warlin Garcia · Apr 13, 2018 go to post

Not sure exactly what you're trying to do or what problem  you're exactly facing (more details would be helpful) but, assuming you're trying to handle the soap body yourself instead of what the wizard generated then you can create a method to create the body and add the name to the WriteSOAPBodyMethod  property of the client class. It's not recommended to call Cache internal methods in your code. It's better to use any provided "hooks" if available.

Warlin Garcia · Jan 25, 2018 go to post

If you want to check on the result of a LOCK command for example 

LOCK +<SOMERESOURCE>:<timeout>

IF $T {do something}

So I wouldn't call it bad practice just yet.

Warlin Garcia · Jan 24, 2018 go to post

Agree with brace always. This really helps with new developers as the syntax is something they've seen before in other languages. 

Warlin Garcia · Jan 12, 2018 go to post

I understand the accessing part but by creating a class mapping I'm enabling SQL access to the existing global. I guess that the question is more in line on whether sharding will be able to properly partition (shard) SQL tables that are the result of global mapping? Are there any constraints on how the %Persistent class (and the storage) is defined in order for it to work with sharding? Should they all use %CacheStorage or can they use %CacheSQLStorage (as with mappings)? 

Warlin Garcia · Jan 12, 2018 go to post

Let's say I have an orders global with the following structure:

^ORD(<ID>)=customerId~locationId.....

And I create a mapping class for this global: MyPackage.Order

Can I use sharding over this table?

Warlin Garcia · Jan 12, 2018 go to post

Alex, it's all based on your design. The decision of whether a method is an instance or class method is totally independent of whether that method can be private or not. Your design, and patterns or best practices you want to follow, will dictate which way to go. The benefits are in what you want to accomplish with the design: ease of testing, ease of change, etc. 

Warlin Garcia · Jan 11, 2018 go to post

1) The reasons for using both together are purely based on your application's need and design. Some design patterns specify desired visibility of methods for example.

2) Safe depends on the context but it's usually easier to move from a restricted mode to a non-restricted one. Moving methods from private to public shouldn't have any impact on your application (functionality wise). However, the opposite is not true and will require you to modify your code to fix the parts that were accessing previously public methods that are private now. This will also impact clients of your code (API) as they'll face the same challenges with the new restrictions.

Warlin Garcia · Jan 11, 2018 go to post

Can we infer form this that sharding can be applied to globals that have been mapped to classes (thus providing SQL access)?

Warlin Garcia · Oct 3, 2017 go to post

The easiest way would be to change the definition from list to array. But if you can't do that the next easier thing is to change the STORAGEDEFAULT parameter to 'array'.  Both options will project the collection as a separate SQL table that you can join with.

Warlin Garcia · Jul 19, 2017 go to post

Can you add more information as what is the exact problem you're facing?

If you're accessing the database through ODBC you can craft the query with any name you need to. With that said, your option of having a variable with the name + a date should work as long as this variable is within your application (client). 

If what you want is for the database to handle the variable and the logic to assemble the table name then you need to go with a stored procedure as mentioned by Eduard.

Warlin Garcia · Jul 19, 2017 go to post

The only "caution" here is that referencing the property by name only works with properties where the SqlFieldName corresponds to a valid Cache property name:

  1. Property myproperty As %String;
  2. Property myproperty As %String [SqlFieldName = "mysqlname"];
  3. Property myproperty As %String [SqlFieldName="my_property"];

You can access #1 & #2 by property name, however #3 you can only access by using %Get("my_property");

Warlin Garcia · Jun 22, 2017 go to post

Can you provide more details on what exactly you're trying to accomplish? As you said, the last query works. What exactly is missing? Are you trying to get a prompt (outside of Cache I'm guessing) with the parameter name?

Warlin Garcia · Jun 13, 2017 go to post

Cache doesn't provide this "out of the box" but you can always create a class that works as a Collection (a collection of IDs if you will) and provides an Iterator interface/functionality for to you iterate over the values.  You can always expose and access data through Objects as you need to.

Warlin Garcia · Jun 13, 2017 go to post

There's no easy way for this (as far as I know) as most of this information is "hardcoded" to be written that way in the methods. 

You can always extend the WebRequest class (and its parents) and modify the methods to write the XML in a single line or however you want. However, this is very tedious and carries a lot of problems with each upgrade. 

Warlin Garcia · Jun 13, 2017 go to post

$ORDER would do. Not the cleanest (or preferred) but the point being you can do without SQL.

Warlin Garcia · Jun 13, 2017 go to post

You can manage without. You have plenty of Object Oriented options to get to the items.  Or you could use $O over the global to get the IDs (similar to what Extent would do)

Warlin Garcia · Jun 12, 2017 go to post

I guess it depends on which context you're referring to essential.

If you are working on a pure Cache environment you can probably go without the SQL layer. However, you need SQL to expose data to the world (e.g. reporting tools that can only connect through xDBC layer).

In terms for performance you can always make the case that SQL is slower when compared to direct global access, however SQL provides more "readability" for new (and not so new) developers since SQL is "standard" (or wider spread)  compared to ObjectScript.

My rule is to always chose SQL over direct global access unless the performance requirements can only be met by the latter. 

Warlin Garcia · Jun 7, 2017 go to post

Can you elaborate on this: "For performance reasons we suggest using Foreign Keys instead of relationships."

My understanding is that Relationships will create the foreign keys (and the relationship table) for you similar as you would do in the relational world:

TableA

AID

TableB

BID

 

TableABRelationship

AID

BID

FK: AID

FK: BID

Warlin Garcia · Jun 7, 2017 go to post

The 3 options yield the "same" results, however, depending on needs, one requires more work on your part than the other. With Relationships, for example, Cache automatically handles all referential integrity for you (foreign keys are automatically generated for you). Whereas the other options don't provide that and you're required (depending on your needs) to code  the referential checks (e.g. declare foreign keys).