Is there a way to determine where a record stops? What attribute line number?

154 views
Skip to first unread message

Susan Har

unread,
Jun 8, 2017, 12:23:41 PM6/8/17
to Pick and MultiValue Databases
Hi,

I have to figure out where a record stops so I can correct some data.  We have been on the system for 20 years, (now is on U2)  and have a lot of old chestnuts that stopped short length-wise compared to newer records that have been added.

Example;  I have 16,000 records that might find the end of file at attribute 53.   I might have another 20,000 records that continue on to attribute 85.    There is no consistency here, and I need to make them all the same length so I can then write a value to attribute 56 -

Any ideas on how to determine which records might stop at 53?  

Thanks,

Sue

Martin Phillips

unread,
Jun 8, 2017, 12:32:14 PM6/8/17
to mvd...@googlegroups.com

Hi Susan,

 

If you want to do this in a program, use something like

   HI = DCOUNT(REC, @FM)

where REC is the record and HI will be returned as the number of fields/attributes.

 

I am unclear why you want to make the change anyway as the dynamic array that represents the record will sort out the mark characters automatically if you write to field 56. The real question should be what is in these later fields and are you going to overwrite valuable data?

 

 

Martin Phillips
Ladybridge Systems Ltd
17b Coldstream Lane, Hardingstone, Northampton NN4 6DB, England
+44 (0)1604-709200

--
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

Scott Ballinger

unread,
Jun 8, 2017, 4:27:57 PM6/8/17
to Pick and MultiValue Databases
Hi Susan,

As Martin indicated, U2 records are dynamic.
If you have a RECORD with only two attributes you can still

READ RECORD FROM FILE,ID THEN
  RECORD<85> = "XXX"
  WRITE RECORD ON FILE,ID
END

and attributes 3 through 84 will be initialized to null with no ill consequences (in fact they don't actually get "initialized"- given the case above where the last attribute of RECORD is <2>, if before referencing RECORD<85> you did X = RECORD<84> then X would be null).

/Scott Ballinger
Pareto Corporation
Edmonds WA USA

To unsubscribe, email to: mvdbms+unsubscribe@googlegroups.com

Ed Clark

unread,
Jun 8, 2017, 6:21:55 PM6/8/17
to mvd...@googlegroups.com
If you’re using a database that supports i-types (universe and unidata do), you can create an item in the file dictionary:

     ATTRBCNT
0001 I
0002 DCOUNT(@RECORD,@AM)
0003
0004 CNT
0005 5R

and then use a query like:

LIST filename ATTRBCNT
or 
SELECT filename WITH ATTRBCNT < "85"
to get a list of the items that stop short of the fields you are interested in filling in.



To unsubscribe, email to: mvdbms+un...@googlegroups.com

fwinans

unread,
Jun 9, 2017, 2:50:16 PM6/9/17
to Pick and MultiValue Databases
Or in D3 make an md item ATTRBCNT {being in md instead of dict of a given filename makes it a feature global to all files}
   ATTRBCNT
001 s
002 0
003 attribs
004
005
006
007
008 u201e
009 r
010 8
011
012
013
014
015
016
017 usage: sort   myfile   total    attrbcnt

Or if you hate user exits, change line 008 to be CALL  myprogs attrbcnt_source
and  compile item attrbcnt_source in file myprogs that is
001 subroutine attrbcnt_source(my_io)
002  myfile = access(1)
003 id = access(10)
004 item = access(3)
005 my_io = dcount(item,@AM)
006 return

or line 8 of md attrbcnt can be just CALL  attrbcnt_source
     without the word   myprogs 
     if you both compile and catalog myprogs attrbcnt_source

Dennis Bartlett

unread,
Jul 4, 2017, 9:31:34 AM7/4/17
to Pick and MultiValue Databases
Any ideas on how to determine which records might stop at 53?  


So what happens, do we provide the solution to the problem or do we answer the OP's question?

The question she asked is a valid one, but isn't the solution required.

One can find the last attribute or a record by counting the number of lines, but Sue's issue is how to add a value into field 85.

The answer, Sue, as stated above, is that you don't have to calculate the number of field marks to append to a record in order to get to 85 - you simply say REC<85> = X and the system will insert however many field marks are required.

Your question however does imply you haven't worked with multivalue databases before?  

Will Johnson

unread,
Jul 5, 2017, 2:19:57 PM7/5/17
to Pick and MultiValue Databases
Right.  You do not need to make all the records the same length in order to write a value to field 56

As Dennis said you simply do something like

Read Record from File, Item THEN
   Record<56> = "Hello World"
   Write Record on File, Item
END

The system will *automatically* insert value marks to count up to 56 for you, if they don't exist already
If they do, it will simply overwrite that location

So in both cases you get exactly what you are after, without the need to cycle through the entire file.

George Gallen

unread,
Jul 5, 2017, 2:40:06 PM7/5/17
to mvd...@googlegroups.com

yes, this was something that php (and others) does not do with an array.

$a="";

$a[0]="1"

$a[2]="3"

$a[100]="4"

echo count($a)."\n";


Will show you 3


Whereas in UV

A=""

A<1>=1

A<4>=3

A<100>=4

PRINT DCOUNT(A,CHAR(254))


Will show you 100


I ran into this when I attempting to port a UV program to PHP and took me a while to

realize that count was not the same as the highest key value.



George


From: 'Will Johnson' via Pick and MultiValue Databases <mvd...@googlegroups.com>
Sent: Wednesday, July 5, 2017 2:19 PM

To: Pick and MultiValue Databases
Subject: [mvdbms] Re: Is there a way to determine where a record stops? What attribute line number?
 
Reply all
Reply to author
Forward
0 new messages