cancel
Showing results for 
Search instead for 
Did you mean: 

VMS Sort

Kurt Wiseth
Occasional Visitor

VMS Sort

Is is possible to read soted records twice from the same sort-merge using the sor$return_rec function, if so, where can I find an example of that

Thanks
Kurt
6 REPLIES
Karl Rohwedder
Honored Contributor

Re: VMS Sort

As far as I understand the docs, each call to the function returns the next record until an end-condition is signalled.
What do you want to achieve?

regards Kalle
Kris Clippeleyr
Honored Contributor

Re: VMS Sort

Kurt,
Welcome to the OpenVMS forum.
I'm not sure if what you're asking is at all possible. But, is that really necessary?
SOR$RETURN_REC returns a record in a user buffer, so you have it already under program control. Why do you want to read it a 2nd time? If you need that record a 2nd time, you can simply copy the contents to elsewhere in the program. What are you trying to accomplish?
Regards,
Kris (aka Qkcl)
I'm gonna hit the highway like a battering ram on a silver-black phantom bike...
Kurt Wiseth
Occasional Visitor

Re: VMS Sort

Thanks for the reponses,

I'm merging information from three different sorts and then printing out some information.

for example I'm reading information from a customer table and puting the information in one sort, then I'm reading information from an invoice header table and putting that in another sort and I'm also reading information from an invoice detail table and putting that information in another sort.

I know it's possible to filter when reading information from a tables, but in our case it's much faster to do full table scan and put the inforamtion into sort and then merge the information I want to print out.

I would like to print out customer information along with number of invoices and average $ amount.

I know I can setup more sort or arrays to tack this, but I was wondering if it is possible read a recot from a sort of customers and then get the number of invoices for each customer from the invoice header sor and store the number in the sort record so I can read it later when it comes time to print it out.

Kurt
Karl Rohwedder
Honored Contributor

Re: VMS Sort

This sounds as if you are using a database as datasource, if so wouldn't be some SQL magic the right tool to use to combine data of this 3 tables?

regards Kalle
Klaes-Göran Carlsson
Frequent Advisor

Re: VMS Sort

Why spend time on it when you can do it in one simple select statment?
Guess answer on that is license cost, then, have you tried the cheap "database" called "rms indexed files"?
Antoniov.
Honored Contributor

Re: VMS Sort

Hi,
I don't know how solve with merge/sort utility.

I think you could:
1.Create a copy of customer file, indexed by customer code.
2.Create a copy of invoice header file, indexed by invoice number.
3.Sort invoice rows by invoice number and row number.
4.Open for write a new empty file.
5.Read a record from sorted rows file;
5b.Extract invoice number from row record and then use it to read invoice header from indexed copy.
5c.Extract customer code from invoice header record and then use it to read customer record from indexed file.
6.Merge all informations as you prefer.
7.Write new merged record.
8.Read next record and loop at 5.
9.Close all files.
10.Delete indexed copies of files.
11.Good luck.

Antonio
http://it.openvms.org
Antonio Maria Vigliotti