An explainer for LOCATE, INSERT, DELETE and sorting

21 views
Skip to first unread message

Nivethan T

unread,
8:08 AM (11 hours ago) 8:08 AM
to Pick and MultiValue Databases
LOCATE, INSERT and DELETE never quite felt intuitive so I wrote some examples and tests to explain things to myself.


Optimus01010101

unread,
9:43 AM (9 hours ago) 9:43 AM
to Pick and MultiValue Databases
Like it. I may use it for junior developers, since a lot of our code uses LOCATE, INSERT and DELETE. BTW, I never felt comfortable with UV/QM's version of LOCATE. It just never felt "friendly" to me, even though I know that it what they were going for. I guess being old school can be a draw back.

Steven Martin Trimble

unread,
10:02 AM (9 hours ago) 10:02 AM
to mvd...@googlegroups.com
very nicely done!

CDMI
Steven Trimble
(501) 772-3450 cell/text


On Mon, Mar 23, 2026 at 7:08 AM Nivethan T <thniv...@gmail.com> wrote:
LOCATE, INSERT and DELETE never quite felt intuitive so I wrote some examples and tests to explain things to myself.


--
You received this message because you are subscribed to
the "Pick and MultiValue Databases" group.
To post, email to: mvd...@googlegroups.com
To unsubscribe, email to: mvdbms+un...@googlegroups.com
For more options, visit http://groups.google.com/group/mvdbms
---
You received this message because you are subscribed to the Google Groups "Pick and MultiValue Databases" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mvdbms+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mvdbms/0e20c843-ffa2-4ee2-8561-1ab695534085n%40googlegroups.com.

Steven Martin Trimble

unread,
10:14 AM (9 hours ago) 10:14 AM
to mvd...@googlegroups.com
Interesting, can't speak for Universe, but I can speak for QM
Here is a snippet from the QM documentation (Notice how you can really HAVE IT YOUR WAY) 😃

Default Style

 

The default style  of LOCATE is as found in products such as Prime Information, PI/open and with certain mode settings in UniVerse and Unidata.

 

If only field is specified, LOCATE searches for a field that matches string. If field and value are specified but subvalue is omitted, LOCATE searches for a value within the specified field that matches string. If fieldvalue and subvalue are specified, LOCATE searches for a subvalue within the specified field and value that matches string.

 

Searching commences at the starting position defined in the IN clause. If a match is found, var is set to its field, value or subvalue position as appropriate to the level of the search. If no match is found, var is set to the position at which a new item should be inserted. For an unordered LOCATE this will be such that it would be appended.

 

Note that the syntax actually reads incorrectly. A LOCATE statement such as

LOCATE DT IN DATES<1> SETTING POS THEN ...

is not searching in DATES<1> at all. It is searching starting at DATES<1>.

 

 

UniVerse Style

 

Pick and Reality systems and the UniVerse database running in Ideal, Pick, Reality or IN2 flavour uses the IN clause to identify the item to be searched, not the starting position. The starting position is assumed to be the first item in the data but may be specified explicitly in the command by including the start item.

 

This format of LOCATE can be selected by including a line

$MODE UV.LOCATE

in the program on a line preceding the LOCATE statement.

 

 

Pick Style

 

The original Pick database used a very different syntax which can be used in QM without any special mode settings. Note that despite the presence of brackets, this is a statement and should not be confused with the LOCATE() function described below.

 

 

In all three styles, the THEN clause is executed if the string is found in dyn.array. The ELSE clause is found if the string is not found.

 

In QMBasic, unlike other multivalue environments, the SETTING clause is optional. If omitted, the THEN or ELSE clause is executed as described above but no positional information is returned.

 

Note that this syntax, as found in Information style multi value products, is actually illogical. The IN clause does not specify the data within which to search. Instead it specifies the start position for the search. The alternative syntax enabled by the UV.LOCATE compiler mode and described below is more logical. This syntax is found in Pick, Reality and some flavours of UniVerse.

 

Feel free to peruse here for QM documentation (I love this format):

https://qmhelp.cdmiweb.com/


CDMI
Steven Trimble
(501) 772-3450 cell/text

--
You received this message because you are subscribed to
the "Pick and MultiValue Databases" group.
To post, email to: mvd...@googlegroups.com
To unsubscribe, email to: mvdbms+un...@googlegroups.com
For more options, visit http://groups.google.com/group/mvdbms
---
You received this message because you are subscribed to the Google Groups "Pick and MultiValue Databases" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mvdbms+un...@googlegroups.com.

Nivethan T

unread,
11:26 AM (7 hours ago) 11:26 AM
to Pick and MultiValue Databases
That documentation style is fantastic, reminds me of the D3 reference as well which Rocket seems to have gotten rid of in favor of their crappy new site.

I would love something like that for UV

Steven Martin Trimble

unread,
11:30 AM (7 hours ago) 11:30 AM
to mvd...@googlegroups.com

Jay LaBonte

unread,
2:59 PM (4 hours ago) 2:59 PM
to mvd...@googlegroups.com

I agree, the format and structure is greate but is fails to mention the follows syntax supported in some Mutlivalue versions:

LOCATE element IN dyn.array<attribute.expr,val.expr,subval.expr>,var BY search.type SETTING location THEN

Statements

END ELSE

statements     

END                                                                         

 

Regards,

Jay LaBonte

Reply all
Reply to author
Forward
0 new messages