Two queries related in UniObjects for .NET

172 views Asked by At

Context

I have a interface in VB.NET that extract the data from the UniVerse using UniObjects for .NET

Problem

From the COB file I need to get all keys where the FEC.COB field is equal to a specific date and the field SEC is equal to 04.

An expert in UniVerse Database told me that I can run the follow queries:

SELECT COB WITH FEC.COB > “31/10/2013”

SELECT.ID 1 2 04

But I don't know how can I do that with UniObjects library. Can anyone help me?

1

There are 1 answers

0
Van Amburg On

I don't use UniObjects as my shop normally gets data our of UniVerse via ODBC. Also my VB is bad, so I don't have much metacode for you, but the basic idea would be to do something like this.

1.) Create a UV Session. Hopefully you have that much worked out as I can be of next to no help there.

2.) Once the session is established Execute your query by doing something like this

session.Command.Text = "SELECT COB WITH FEC.COB > '31/10/2013'"
session.Command.Exec

(I converted your double quotes to single quotes and Universe won't mind).
3.) If you just need the IDs, you can get them by iterating through the select list that your query returns. A command line query will always return to list 0 unless you specify otherwise in your UV query. In most cases your results will be in session.SelectList(0)

Dim objSelect As object
Set objSelect = objSession.SelectList(0)

4.) It looks like the SelectList object has a ReadList method which returns a Dynamic Array Object, which you should be able to iterate through using normal array looping. Additionally you can use a while loop and next to do what you need to do.

Dim someObject as Object 
someObject = objSelect.Next ' Get first ID
Do While Not objSelect.LastRecordRead
   ' Do something here with someObject. Maybe ToString it or something
   someObject = objSelect.Next' Get next ID
Loop

Hope that is somewhat helpful.