Retrieve all records from universe database using universe basic subroutine

2.2k views Asked by At

I just want to know that how to retrieve all the record from universe database table using universe basic subroutine.I am new in universe.

4

There are 4 answers

0
ScaryMinds On
OPEN '',FILENAME TO F.FILE ELSE STOP

SELECT F.FILE

 LOOP
    READNEXT K.FILE ELSE EXIT
    READ R.FILE FROM F.FILE, K.FILE ELSE NULL
    PRINT R.FILE
  REPEAT

  PRINT "All over Red Rover"
  • Filename should be in quotes, i.e "MYFILE" or 'MYFILE'

  • The loop will repeat till all records have been read and will then exit.

0
Rajan Kumar On

There is an article and sample code on GitHub on how to execute U2 UniVerse Subroutine.

Execute Rocket MV U2 Subroutine Asynchronously using C# (async\await) and U2 Toolkit for .NET. Convert Subroutine Multi-Value Output to Json/Objects/DataTable

These sample code are based on C# (async\await), but you can use for synchronous programming as well with little code tweak.

For article:

Go to this link :

https://github.com/RocketSoftware/multivalue-lab/tree/master/U2/Demos/U2-Toolkit/AsyncAwait/Execute_Subroutine_Async

Read ‘Subroutine-Async.docx’ file.

Sample Code for this article on GitHub

Go to this link :

https://github.com/RocketSoftware/multivalue-lab/tree/master/U2/Demos/U2-Toolkit/AsyncAwait/Execute_Subroutine_Async

3
Mike On

Can you provide more information on what you are trying to do?

Having a subroutine call return the entire contents of a UniVerse file could return a large amount of data. I would expect you would be better off only returning a subset of the items so the calling routine can process a bit at a time.

New content based on comment:

Ok, since you mentioned a type 19 file, I assume you want to read one file from the directory/folder the file points to.

In your subroutine, you can use OPEN on the type 19 file, and use the READ command to read the file. ( Note that you can also use READU, READL, MATREAD, MATREADU, or MATREADL to get the entire file in the directory/folder, depending on if/how you want to lock the item and if you want the data in a dynamic or dimensioned array. If you only need a specific attribute you can then use READV, READVL or READVU commands.

Or, since this is a type 19 file, you can use sequential reads. Open the file with OPENSEQ and read with the READSEQ or READBLK command.

0
Symeon Breen On

Perhaps something like this in the unibasic

OPEN "filename" to FIL ELSE STOP 201,"cannot open filename"
EXECUTE "SELECT filename"
LOOP WHILE READNEXT ID
READ REC FROM FIL,ID ELSE REC = "" 
 * you now have the entire row in REC

REPEAT